I am not sure as to why. But the code I have created below is not working. The variable: "$num_rows" is not even being set and has no value (not even 0). Anyone know as to why this issue is occurring?
$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;
}
Your syntax is off.
while($row2 = mysql_fetch_array($result2))
$num_rows = mysql_num_rows($result2);
{
should probably be
$num_rows = mysql_num_rows($result2);
while($row2 = mysql_fetch_array($result2))
{
You did it the wrong order.
$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;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.