Jump to content

[SOLVED] checking to see if select returns nothing


envexlabs

Recommended Posts

You'd use the PHP function called mysql_num_rows, this function will return how many results have been returned from the query, eg:

$sql = 'SELECT * FROM `table` WHERE `ID` = 5';
$result = mysql_query($sql);

// check to see if the returned rows is greater than zero
if(mysql_num_rows($result) > 0)
{
   // result has been returned

  // process the results
}
else
{
   // no results was returned, we'll display a message
   echo 'No results returned';
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.