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!!! Quote 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. Quote 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' Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.