Counting Number Of Classifieds In Category
<p>I have a table <code>categories</code> that has: <code>id, name, subcategory_id, parent_id</code>.  Another table <code>classifieds</code> that has: <code>classified_id, title, description, category_id</code>.</p>

<p>I am trying to to pull numbers of classifieds in each category. So it will look like this.</p>

<ul>
<li>Accessories(10)</li>
<li>Cars(15)</li>
<li>Dating(12)</li>
</ul>

<p>I gave it a try like this:</p>

<pre class="lang-php prettyprint-override"><code>enter $catquery  = mysql_query("SELECT * FROM categories WHERE sub_id = '0' ORDER BY name ASC"); here

enter  $catrows = mysql_num_rows($catquery);  here
enter $catrows = mysql_num_rows($catquery); here
enter $query = "SELECT category_id, COUNT(title) AS `total` FROM classifieds WHERE classified_id = 'category_id' "; here
enter $result = mysql_query($query); here
enter while($row = mysql_fetch_assoc($result)){ $num_items_in_category[$row['category_id']] = $row['total'];  here

enter } echo "&lt;li&gt;&lt;a href='category.php?cat=".$row['id']."'&gt;".$row['name']. $row['total']. "&lt;/a&gt;&lt;/li&gt;"; here
</code></pre>

<p>Thanks fellas</p>
