
<table border="0" cellspacing="0" cellpadding="0" width="100%" align="CENTER">
<tr> 
<td><img src="images/ltl.png"></td>
<td background="images/lt.png"></td>
<td><img src="images/ltr.png"></td>
</tr>
<tr> 
<td background="images/sf-l.jpg"></td>
<td class="td2" width="100%" bgcolor="#FFFFFF" nowrap> <span class="font2"> Categories</span><br>
<br>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<?php if (!empty($_GET[category])) { ?>
<tr> 
<?PHP
$SQLc = "SELECT * from CATEGORIES WHERE ID = '$_GET[category]'"; $resultc = @mysql_query( $SQLc ); $rowc = @mysql_fetch_array( $resultc );
$lastcat = $rowc[CATEGORY];
if (empty($rowc[CATEGORY])) { ?>
<td><a href="index.php"><img src="images/arrow-up-green.png" width="16" height="16" border="0"></a></td>
<?PHP
} else { ?>
<td><a href="<?PHP mr("dirbrowse", "$rowc[CATEGORY]", "$rowxxx[MR]", "?page=browse&category="); ?>"><img src="images/arrow-up-green.png" width="16" height="16" border="0"></a></td>
<?PHP } ?>
<td class="td4" width="100%"><a href="index.php"><b>Categories</b></a></td>
</tr>
<?PHP } ?>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<?PHP

$SQLc = "SELECT * from CATEGORIES WHERE CATEGORY = '$_GET[category]'"; $resultc = @mysql_query( $SQLc ); $rowc = @mysql_fetch_array( $resultc );
if (empty($rowc[CATEGORY])) { $wherearewe = top; }

$SQLc = "SELECT * from CATEGORIES WHERE CATEGORY = '$_GET[category]'"; $resultc = @mysql_query( $SQLc ); $rowc = @mysql_fetch_array( $resultc );
if (!empty($rowc[CATEGORY]))  { $wherearewe = notbottom; }
if (empty($rowc[CATEGORY])) { $wherearewe = bottom; }

if ($wherearewe == top) $category = '';
if ($wherearewe == notbottom) $category = $_GET[category];
if ($wherearewe == bottom) $category = $lastcat;


$SQLcaT = "SELECT * from CATEGORIES WHERE CATEGORY = '$category' ORDER BY TITLE ASC";
$resultcaT = @mysql_query( $SQLcaT ); while( $rowcaT = @mysql_fetch_array( $resultcaT ) ) {

?>

<?PHP 

$link = "?page=browse&category=$rowcaT[ID]";

if ($rowxxx[MR] == Enabled) {
	if ($rowcaT[TITLE] != '')

		$link = EdURL($rowcaT[TITLE]);
}
?>

<tr> 
<?php if ($rowcaT[CATICON] != '') { ?>
<td class="td4"> <img src="category_icons/<?php echo $rowcaT[CATICON]; ?>"> </td>
<?PHP } ?>
<td class="td4" width = 100% colspan="2" nowrap><a href="<?PHP ECHO $link; ?>"> 
<?php echo $rowcaT[TITLE]; ?>
</a> 
<?PHP

if ($rowxxx[COUNT_LISTINGS] == $nil || $rowxxx[COUNT_LISTINGS] == Yes) {




        $sql_count      = "SELECT count(*) FROM PAGES WHERE CATEGORY LIKE '%-$rowcaT[ID]-%'";
        $res_count      = @mysql_query($sql_count);
        $row_count      = @mysql_fetch_row($res_count);

$total = $row_count[0];

        if ($total != $nil) echo " <span class=itty_link>($total)";

}

//---------------------------------------------------------------------------
?>
</td>
</tr>
<?PHP } ?>
</table>
</td>
<td background="images/lr.png"></td>
</tr>
<tr> 
<td><img src="images/lbl.png"></td>
<td background="images/lb.png"></td>
<td><img src="images/lbr.png"></td>
</tr>
</table>
