Thursday, October 11, 2012

How can i tell if a MySQL query returned nothing in PHP?


Its simple.. use mysql_num_rows as shown below....


$query_req="SELECT * FROM customer";
$query_result=mysql_query($query_req);

if (mysql_num_rows($query_result) != 0)
{
   echo "More than 0 records were returned.";
}

No comments:

Post a Comment