Far Cry Posted November 17, 2010 Share Posted November 17, 2010 How do you do this? Thanks in advance. 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. 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
Archived
This topic is now archived and is closed to further replies.