Hi,
I want to use nested tables to build top level categories and sublevel categories.
Is this bad practise and will it make server load very high?
Here is my code for an include (built with Dreamweaver):
<?php require_once('../../Connections/hhdb.php'); ?>
<?php
mysql_select_db($database_hhdb, $hhdb);
$query_rsTopCat = "SELECT * FROM tbl_top_cat ORDER BY top_cat_name ASC";
$rsTopCat = mysql_query($query_rsTopCat, $hhdb) or die(mysql_error());
$row_rsTopCat = mysql_fetch_assoc($rsTopCat);
$totalRows_rsTopCat = mysql_num_rows($rsTopCat);
?>
<table width="180" border="0" align="center" cellspacing="0" cellpadding="0">
<tr>
<td height="27" align="center" class="sideContentTitle">Categories</td>
</tr>
<tr width="100%">
<td width="100%" class="sideContentCopy">
<?php do { ?>
<strong><?php echo $row_rsTopCat['top_cat_name']; ?></strong><br>
<?php mysql_select_db($database_hhdb, $hhdb);
$top_cat_id = $row_rsTopCat['id'];
$query_rsSubCat = "SELECT * FROM tbl_categories where top_cat_id='$top_cat_id' ORDER BY cat_name ASC";
$rsSubCat = mysql_query($query_rsSubCat, $hhdb) or die(mysql_error());
$row_rsSubCat = mysql_fetch_assoc($rsSubCat);
$totalRows_rsSubCat = mysql_num_rows($rsSubCat); ?>
<?php do { ?>
<img src="/gen_pix/bullet.gif" width="7" height="5"> <a href="/site/ads/index.php?cat=<?php echo $row_rsSubCat['id']; ?>" class="contentLink"><?php echo $row_rsSubCat['cat_name']; ?></a><br>
<?php } while ($row_rsSubCat = mysql_fetch_assoc($rsSubCat)); ?>
<?php } while ($row_rsTopCat = mysql_fetch_assoc($rsTopCat)); ?> </td>
</tr>
<tr>
<td height="6"><img src="/gen_pix/sidesbottom.gif" width="180" height="18"></td>
</tr>
</table>
<?php
mysql_free_result($rsSubCat);
mysql_free_result($rsTopCat);
?>