All pastes #365795 Raw Edit

Anonymous

public text v1 · immutable
#365795 ·published 2007-02-21 06:39 UTC
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>

<? } ?>