View Single Post
Old 03-28-2006, 04:31 AM   #5 (permalink)
bayruni
Registered User
 
Join Date: Mar 2006
Posts: 9
bayruni is on a distinguished road
It works! But...

Quote:
Originally Posted by sde
or something like this:
PHP Code:
<?
$result 
mysql_query("select c.category_name, count(a.article_id) as count from np_categories as c
  left join np_articles as a on c.category_id=a.article_category_id
  group by c.category_id
  order by c.category_name"
);

while (
$row mysql_fetch_assoc($result)) {
  echo 
$row['category_name'] . " (" $row['count'] . ")<br />\n";
}
Thank you so much! This option worked perfect. However, what if I already have a list of my categories in a table and only want to display the number of articles in the category - and not the entire list again?
bayruni is offline   Reply With Quote