I have a loop picking up some data from a MySQL query but if it doesn't find anything I want it to print out something else. Obviously if I use mysql_fetch_arr ay() to test it, my while loop will not pick up the first value so here is what I have:
I have tried putting the if statement in the while loop, but very quickly realised how dumb that was because the while loop was not running if it is empty. So is there a while/or function or something which can check if a query is empty without affecting fetching?
Code:
$raw_msgs = mysql_query("SELECT...") or die(mysql_error());
if (empty($raw_msgs)) { echo("No messages."); }
while ( $msgs = mysql_fetch_array($raw_msgs) ) {
echo("...");
}
Comment