我不确定为什么。但是我在下面创建的代码不起作用。变量:"$num_rows"甚至没有被设置,也没有值(甚至没有0)。有人知道为什么会出现这个问题吗?
$result2 = mysql_query("SELECT * FROM `mycity_vehicles` WHERE `id` = '$vehID'");
while($row2 = mysql_fetch_array($result2))
$num_rows = mysql_num_rows($result2);
{
if(empty($num_rows)) {
echo "empty";
}
else {
echo $num_rows;
}
您的语法已关闭。
while($row2 = mysql_fetch_array($result2))
$num_rows = mysql_num_rows($result2);
{
应该是
$num_rows = mysql_num_rows($result2);
while($row2 = mysql_fetch_array($result2))
{
你做的顺序错了。
$result2 = mysql_query("SELECT * FROM `mycity_vehicles` WHERE `id` = '$vehID'");
$num_rows = mysql_num_rows($result2);
while($row2 = mysql_fetch_array($result2)) {
if(empty($num_rows)) {
echo "empty";
}
else {
echo $num_rows;
}