Fsoft Posted July 19, 2009 Share Posted July 19, 2009 `Hello, $query10 = mysql_query("SELECT * from articles where art_cat = $cat"); echo " "; echo "There are "; $count = 0; while($query11 = mysql_fetch_array($query10)) { $countfinal = $count+1; } echo $countfinal; } Sir, I am stuck here, I have 19 articles in my table, And I want to echo out "There are 19 articles." Using this code it only gives out There are 1 articles.. I don't know why this code is not working Please help, thanks. FAISAL!!! Link to comment https://forums.phpfreaks.com/topic/166532-solved-counting-all-the-entires-in-database/ Share on other sites More sharing options...
Paradoxz Posted July 19, 2009 Share Posted July 19, 2009 I am new so don't take this to heart, but $count = 0; is 0 $countfinal = $count+1; is 0 + 1 echo $countfinal; is going to say 1 I think you need to count the rows. Don't remember the script though. Link to comment https://forums.phpfreaks.com/topic/166532-solved-counting-all-the-entires-in-database/#findComment-878211 Share on other sites More sharing options...
Michdd Posted July 19, 2009 Share Posted July 19, 2009 Do this: $query10 = mysql_query("SELECT COUNT(id) from articles where art_cat = $cat"); $row10 = mysql_fetch_assoc($query10); echo "There are {$row['COUNT(id)']} articles"; Change COUNT(id) to another row in that table if you don't have 'id' Link to comment https://forums.phpfreaks.com/topic/166532-solved-counting-all-the-entires-in-database/#findComment-878213 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.