Home > DeveloperSection > Interviews > How can we find the number of rows in a result set using PHP?

Posted on    June-13-2011 5:05 AM

 PHP PHP 
Ratings:
 1 Answer(s)
  1080  View(s)
Rate this:

Awadhendra Tiwari

Total Post:510

Points:2550
Posted on    June-13-2011 12:00 AM

Here is how can you find the number of rows in a result set in PHP:

$result = mysql_query($any_valid_sql, $database_link);
$num_rows = mysql_num_rows($result);
echo "$num_rows rows found";

Don't want to miss updates? Please click the below button!

Follow MindStick