Php Programming Code Examples Php > Code Snippets Code Examples Count and display the number of rows in a mysql database table Count and display the number of rows in a mysql database table <?php Connect to the databasedb_connect(); // Query the database and get the count$result = mysql_query("SELECT * FROM tablename"); $num_rows = mysql_num_rows($result); // Display the resultsecho $num_rows;?>