Definition and usage
The mysql_num_rows () function returns the number of rows in the result set.
Grammar
Mysql_num_rows (data)
Parameters |
Description |
Data |
Necessary. The result set. The result set is obtained from the invocation of mysql_query (). |
Description
Mysql_num_rows () returns the number of rows in the result set. This command is valid only for SELECT statements. To get the number of rows affected by the Insert,update or DELETE query, use Mysql_affected_rows ().
Hints and Notes
Note: If you use Mysql_unbuffered_query (), mysql_num_rows () will not return the correct value until all the rows in the result set are extracted.
Example
<?php$con = mysql_connect ("localhost", "Hello", "321"), if (! $con) {die (' Could not connect: '. Mysql_error () ); mysql_num_rows($result)
; Mysql_close ($con);? >
The output is similar to:
3
The PHP mysql_num_rows () function returns the number of rows in the result set.