PHP while循环不执行

时间:2013-09-25 22:18:10

标签: php

以下代码中的我的While循环无效。当我注释掉while行和两个括号时,while循环中的所有内容都很好。一旦我取消注释while循环并再次运行它,我得到没有错误,但内部的所有回声消失。

case 'search':

echo "searching".$firstname;


$sqlsearch="SELECT * FROM Customer WHERE firstname='$firstname'";

$sim = mysql_query($conndb, $sqlsearch);

while($row = mysql_fetch_array($sim))
{
echo "firstname: ".$row['firstname']."<br>";
echo "lastname: ".$row['lastname']."<br>";  
echo "phone: ".$row['phone']."<br>";
echo "address: ".$row['address']."<br>";
echo "city: ".$row['city']."<br>";
echo "state: ".$row['state']."<br>";
echo "zip: ".$row['zip']."<br>";
echo $sqlsearch;
}

echo "<br>";
echo "seaching 2";
break;

1 个答案:

答案 0 :(得分:-1)

要解决这个问题,我必须将行($ row = mysql_fetch_array($ sim))更改为while($ row == mysql_fetch_array($ sim))