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!"; }
?>
More mysql PHP Questions
How do I find the longest value in my mysql table?How do I include a conditional in my mysql query?
How do I find second highest value from a table?
How do I limit the number of rows returned?
How do I update the contents of a table row?