I hope I am looking at the right file (just learning php). My website has navigation links on the left hand side and then subcategories.

I am having two problems. First I am trying to put many different categories but need to have the table split into 3 so the list goes across the page instead of just going downward. I put what I think may be the code at the bottom. Click Here

The second problem is that if you notice by clicking here with the categories expanded that by clicking on an item the bottom of the page is lifted up rather than sitting on the bar like it should. Click Here

I was thinking about using cool menu to expand the left navigation so the bottom links (return to catalog, question send an email ect...) would not be pushed up but would not know how to insert it. Any other suggestions?

Any help with either problem would be greatly appreciated.

The code below:
<?php

$subcatnumrecs=0;

if($maincat){

$subcategoryquery = "SELECT Category, ID, NavImage FROM ".$dbprefix."Categories WHERE Parent = $maincat AND Active <> 'No' AND Parent <> 0 ORDER BY Category";
$subcategoryresult = mysql_query($subcategoryquery) or die ("Unable to access database because ".mysql_error());
$subcatnumrecs=mysql_num_rows($subcategoryresult);

}elseif($category){

//find the parent of the current category and THEN look it up
$parentcategoryquery = "SELECT ID, Parent, Category FROM ".$dbprefix."Categories WHERE ID = $category";
$parentcategoryresult = mysql_query($parentcategoryquery) or die ("Unable to access database because ".mysql_error());
$parentcatnum=mysql_num_rows($parentcategoryresult);

$parentcat=0;

if($parentcatnum!=0){
$parentcatrow=mysql_fetch_array($parentcategoryresult);
$parentcat=$parentcatrow[1];
}

$subcategoryquery = "SELECT Category, ID, NavImage FROM ".$dbprefix."Categories WHERE Parent = $parentcat AND Active <> 'No' AND Parent <> 0 ORDER BY Category";
$subcategoryresult = mysql_query($subcategoryquery) or die ("Unable to access database because ".mysql_error());
$subcatnumrecs=mysql_num_rows($subcategoryresult);

}

if ($subcatnumrecs > 0)
{

echo "<table class=\"subcattbl\">";
echo "<tr>";

while($subcatrow = mysql_fetch_row($subcategoryresult))
{

$finalcatid=$subcatrow[1];
$stripcat = stripslashes($subcatrow[0]);
$subcategoryname = str_replace(" ","&nbsp;",$stripcat);
$splitcat = split("~", $subcategoryname);

//separate category for display (~ was used in old system to differentiate names
if ($splitcat[1])
$subcategoryname = "$splitcat[1]";

//STYLE PART
if ($category == $finalcatid)
echo "<td class=\"subcatcellon\">";
else
echo "<td class=\"subcatcelloff\">";
//STYLE PART

$subcategorylink = $subcatrow[1];

$maincatimage = $catrow[2];

if($maincatimage!=""){
echo "<a href=\"$Catalog_Page?category=$subcategorylink\">";
echo "<img alt=\"$subcategoryname\" src=\"$maincatimage\" align=\"bottom\" border=\"0\"></a>";
}else{
echo "<a href=\"$Catalog_Page?category=$subcategorylink\">$subcategoryname</a>";
}

echo "</td>";
}

echo "</tr>";
echo "</table>";

}



?>