View Single Post
Old 03-27-2006, 03:14 PM   #4 (permalink)
Brent
Registered User
 
Brent's Avatar
 
Join Date: Mar 2006
Posts: 1
Brent is on a distinguished road
My Solution

Here's how I'd do it:

Code:
$result = mysql_query( "SELECT category_id, category_name FROM np_categories ORDER BY category_name ASC" );
while( $row = mysql_fetch_array( $result ) )
	{
	$category_id = $row[0];
	$name = $row[1];
	$data = mysql_fetch_array( mysql_query( "SELECT COUNT(*) FROM np_articles WHERE article_category_id = $category_id" ) );
	$num_articles = $data[0];
	print( "<li> $name ($num_articles)</li>\n" );
	}
Brent is offline   Reply With Quote