DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Call Total Number From MySQL Row

04.17.2006
| 3850 views |
  • submit to reddit
        // Call total count from MySQL row

<?
// Query the database and get the count
$result = mysql_query("SELECT * FROM TABLE_NAME");
$num_rows = mysql_num_rows($result);

// Display the results
echo $num_rows;
?>
    

Comments

Snippets Manager replied on Mon, 2012/05/07 - 2:23pm

why not just SELECT COUNT(id) FROM TABLE_NAME ? It'd be alot faster, and much kinder to your php memory use.