OK I have this code below that gets my categorys. Only one problem though. I also need to get the count from another table for each category.
Where it says $count on the below code, i need it to show the count from a table called subcat and field called categoryg.
category from table category and categoryg from subcat table are same.
So i need the count from subcat where categoryg == category
Table category
id | category
Table subcat
subcatid | categoryg | link
But have no clue on how to edit this so it works.
/* Select all categories from category table */
$query = "SELECT * FROM category ORDER BY catid ASC";
$result = mysql_query($query)
or die ("Couldn't execute query.");
$i = 0;
while ($row = mysql_fetch_array($result))
{
$i++;
if($i == 1)
{
echo "<tr>";
}
extract($row);
echo "<td bgcolor=\"#f2f2f2\" valign='top' width='22%' class='product'>\n";
echo "<img src=\"$SITE_URL/images/folder.gif\" align=\"Middle\" width=\"31\" height=\"30\"> <a href=\"$SITE_URL/Dir/index.php?cate=$category\">$category</a> ($count)</font>
</td>
";
if($i == 3)
{
echo "</tr>";
$i=0;
}
}