MySQL选择问题

I'm building a website to learn coding. I have a claim.php which is a claim your business page (its just a place that you can search for a business and then click a link to addclaimedbiz.php) and a addclaimedbiz.php page which adds the claimed business to the database.

First of all, heres my sql code for the user where the business id will be added to the row biz:

`id` int(15) NOT NULL AUTO_INCREMENT,
`firstname` varchar(50) NOT NULL,
`lastname` varchar(50) NOT NULL,
`email` varchar(75) NOT NULL,
`password` varchar(50) NOT NULL,
`biz` int(1) NOT NULL,
`verifiedbiz` int(1) NOT NULL,

and heres my sql code for the businesses:

`id` int(15) NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
`phone` varchar(14) NOT NULL,
`claimed` int(1) NOT NULL,

Now heres the code for claim.php that sends the company id to addclaimedbiz.php. ( I only posted a little but can post more if you need it!)

 while($row = mysql_fetch_array($result))
            {
            $id=$row['id'];
            $company_name=$row['name'];
            $company_phone=$row['phone'];
            $company_address=$row['address'];
            $address2=$row['address2'];
            $company_city=$row['city'];
            $company_zip=$row['zipcode'];
            $cat1=$row['cat1'];
            $cat2=$row['cat2'];
            $cat3=$row['cat3'];
            $subcat1=$row['subcat1'];
            $subcat2=$row['subcat2'];
            $subcat3=$row['subcat3'];
            $claimed=$row['claimed'];
            //Start While Loop
            echo"
            <div class='listing'>
                                    <li>
                                        <span class='bphone'>$company_phone</span>
                                        <span class='bname'>$company_name</span>
                                        <br/>
                                        <div class='blocation'>$company_address, $company_city, CO $company_zip ";if($address2 != ""){echo"(".$address2.")";}echo"</div>
                                        <br/>
                                        ";if($claimed != 1){echo "<a href='addclaimedbiz.php?id=".$id."'><button>Claim Business</button></a>";}else{echo "Already Claimed";}echo"
                                    </li>

                                <!--/Listing-->

                </div>";

            }

And then heres my code for addclaimedbiz.php:

 <?
 $biz_id = $_REQUEST['id'];

 //This next select from db is to take the id of the company and get the name for the corresponding id

 include("./config.php");
 $result = mysql_query("SELECT * FROM company WHERE id = '$biz_id'") or die(mysql_error());
 while($row = mysql_fetch_array($result))
 {
    $business_name = $row['name'];
 }

 ?>

and then to echo out $business_name i use (this is on addclaimedbiz.php as well just down the page a bit)

<?php if($biz == "0"){

            echo "You are claiming:"$business_name " as your business";

            }
            else{"You are already have a claimed business"}
            ?>

What should be happening is it should echo out You are claiming: $business_name as your business but right now its leaving out $business_name. Why is this?

Major thanks to all help!

Oh and I left out some of the rows in my databases that were unnecessary to the problem I thought, but if you need them I can definitely post!


EDIT


my new code looks like this:

<?
error_reporting(E_ALL);
$auth = $_COOKIE["auth"];
if ($auth != "1"){
header("Location: ./signin.php");
}
$firstname = $_COOKIE['firstname'];
$id = $_COOKIE['id'];
$fname = ucwords($_COOKIE['firstname']);
$lname = ucwords($_COOKIE['lastname']);
$email = $_COOKIE['email'];
$city = ucwords($_COOKIE['city']);
$biz = ucwords($_COOKIE['biz']);

$biz_id = $_REQUEST['id'];

include("./config.php");
$result = mysql_query("SELECT * FROM company WHERE id = '$biz_id'") or die(mysql_error());
if(mysql_num_rows($result)){
    while($row = mysql_fetch_assoc($result)){
        $business_name = $row['name'];
    }
}
echo count($result);
?>

You're not using proper variable interpolation in your string, put $business_name inside the qutoes:

echo "You are claiming:$business_name as your business";

Ah, also looks like you want mysql_fetch_assoc, not mysql_fetch_array:

while($row = mysql_fetch_assoc($result)){
    $business_name = $row['name'];
}

Docs here.

Hmmm...I have a hunch, try wrapping your while block with:

if(mysql_num_rows($result)){
   ...   
}

I'll let someone else do the lecturing on the mysql_* functions. :)

Cheers

You need to concatenate the strings with a period like so:

        echo "You are claiming:" . $business_name . " as your business";

I believe you need to put a couple . in your echo statement.

Like this:

echo "You are claiming: " . $business_name . " as your business";

You need to use . to concatenate strings in php

 echo "You are claiming:".$business_name ". as your business"