rendered paste body<?
$query = "select c.catid, c.name, ( select count(v.id) from vendors v where v.catid = c.catid ) as num_vendors from category c order by c.name asc";
if ( $rsCat = mysql_query($query) ) {
?>
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<th>Category ID</th>
<th>Category Name</th>
<th>Num Vendors</th>
</tr>
<? while ( $row = @mysql_fetch_array($rsCat, MYSQL_ASSOC) ) { ?>
<tr>
<td><?= $row["catid"]?></td>
<td><?= $row["name"]?></td>
<td><?= $row["num_vendors"]?></td>
</tr>
<? } ?>
</table>
<? } else { ?>
<p>
Could not retrieve categories.
<br /><br />
<?= mysql_error()?>
</p>
<? } ?>