Far Cry Posted November 17, 2010 Share Posted November 17, 2010 How do you do this? Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/219016-echo-out-the-number-of-records-in-a-mysql-table-with-php/ Share on other sites More sharing options...
jcbones Posted November 17, 2010 Share Posted November 17, 2010 //Either $sql = "SELECT * FROM table"; $result = mysql_query($sql); echo mysql_num_rows($result) . ' rows found!'; //or $sql = "SELECT COUNT(*) AS count FROM table"; $result = mysql_query($sql); $row = mysql_fetch_assoc($result); echo $row['count'] . ' rows found!'; I would use the first one, if I'm pulling queries to use, and the second one for counts only. Quote Link to comment https://forums.phpfreaks.com/topic/219016-echo-out-the-number-of-records-in-a-mysql-table-with-php/#findComment-1135835 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.