Dysan Posted February 27, 2008 Share Posted February 27, 2008 Hi, Whats the best way to count the total about of records contained inside a table? Link to comment https://forums.phpfreaks.com/topic/93239-count-total-table-records/ Share on other sites More sharing options...
cooldude832 Posted February 27, 2008 Share Posted February 27, 2008 <?php $q = "Select count(*) as table_count from `table`"; $r = mysql_query($q) or die(mysql_error()."<br /><br />".$q; $table_rows = mysql_result($r,0); Link to comment https://forums.phpfreaks.com/topic/93239-count-total-table-records/#findComment-477622 Share on other sites More sharing options...
Dysan Posted February 27, 2008 Author Share Posted February 27, 2008 What does the zero do in this code? mysql_result(mysql_query("SELECT COUNT(*) FROM music"), [b]0[/b]); Link to comment https://forums.phpfreaks.com/topic/93239-count-total-table-records/#findComment-477636 Share on other sites More sharing options...
cooldude832 Posted February 27, 2008 Share Posted February 27, 2008 returns the 0th row of the query i.e the only row and since its one item your good to go Link to comment https://forums.phpfreaks.com/topic/93239-count-total-table-records/#findComment-477637 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.