Are you searching for How can we find the number of rows in a result set using PHP? In this answer, we have shared a PHP script to get the number of rows in a result set using PHP.
PHP mysql_num_rows() function will retrieves the number of rows from a result set. This command is only valid for statements like SELECT or SHOW that return an actual result set.
Following are the example mysql_num_rows() function, which used to number of rows from MySQL table.
Example #1 mysql_num_rows() example
1 2 3 4 5 6 7 8 9 10 11 | <?php $link = mysql_connect("localhost", "mysql_user", "mysql_password"); mysql_select_db("database", $link); $result = mysql_query("SELECT * FROM table1", $link); $num_rows = mysql_num_rows($result); echo "$num_rows Rows\n"; ?> |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.