How do I find the number of rows in a result set?
Here's how it is done, using the mysql_num_rows function which does what it says on the tin.
<?php
$query = "SELECT friends FROM listoffriends WHERE name = 'me'";
$doquery = mysql_query($query);
$myfriendnumber = mysql_num_rows($doquery);//returns integer value
if(!$myfriendnumber) { echo "Sorry, the person 'me' doesn't have any friends"; }
else { echo "The person 'me' has $myfriendnumber friends!"; }
?>
Comment on this Question and Answer >>>
ASK A QUESTION
More mysql PHP Questions
I am unable to make pages for my search result.Below I am giving the code that I am using. Career Search result Yami saysHow do I group the results of a mysql query?
How do I set a default value for ENUM fields in PHP?
How do I order the results of my query?
How do I limit the number of rows returned?
