mysql_num_rows

int mysql_num_rows(mysql result result_handle) 

Gets the number of rows in a MySQL result handle.

Returns:

Integer; NULL on error

Description:

mysql_num_rows() returns the number of rows in the specified MySQL result handle.

Version:

PHP 3+, PHP 4+

See also:

To find the number of fields in a row:

mysql_num_fields() 

To find the number of rows affected by a query:

mysql_affected_rows() 

Example:

Find out how many rows exist in a result handle
 <?php // Included code that connects to a MySQL server and sets a default database // See the MySQL Functions chapter introduction for the source code for the file include ('mysql_connect.inc.php'); // Get the current time and UNIX timestamp $query = "SELECT * FROM user"; // Suppress errors ...

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.