tjmbc Posted May 1, 2008 Share Posted May 1, 2008 Here's my code so far: $query = "SELECT COUNT(*) FROM table"; $result = mysql_query($query); How do I display the result on my page? Link to comment https://forums.phpfreaks.com/topic/103766-putting-mysql-row-count-to-use/ Share on other sites More sharing options...
revraz Posted May 1, 2008 Share Posted May 1, 2008 use AS with count. Link to comment https://forums.phpfreaks.com/topic/103766-putting-mysql-row-count-to-use/#findComment-531262 Share on other sites More sharing options...
phpSensei Posted May 1, 2008 Share Posted May 1, 2008 <?php $query = "SELECT COUNT(*) as phpsensei FROM table"; $result = mysql_query($query); while($row = mysql_fetch_object($query)){ echo $row->phpsensei; } ?> or <?php $query = "SELECT COUNT(*) as phpsensei FROM table"; $result = mysql_query($query); while($row = mysql_fetch_array($query)){ echo $row[phpsensei]; } ?> Link to comment https://forums.phpfreaks.com/topic/103766-putting-mysql-row-count-to-use/#findComment-531265 Share on other sites More sharing options...
moselkady Posted May 1, 2008 Share Posted May 1, 2008 Your result will contain the number of rows in table. So to display this number, just add these 2 lines: $row = mysql_fetch_array($result); echo $row[0]; Link to comment https://forums.phpfreaks.com/topic/103766-putting-mysql-row-count-to-use/#findComment-531277 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.