When we process a select query to get some records from SQL and we want to see how many rows are returned in the query we have a special function for this in php. mysql_num_rows(); using mysql_num_rows function we can get the number of records returned from MySQL query.
mysql_num_rows() Example.
First we need a Query to select some records from database table, once we run query to get results we save that returned results into a variable and we process that variable in mysql_num_rows() function. This is how we can get number of rows mysql returned to our query.
[php]
$query = "SELECT * from users WHERE user_email=’".$email."’";
$query_result = mysql_query($query) or die(mysql_error());
$number_of_rows = mysql_num_rows($query_result);
[/php]
Now we have number of rows in php variable $number_of_rows. To get number of rows we use mysql_num_rows.