Hi Guys,
In order to get an understanding to what i am talking about check out the example i have uploaded at:
http://www.onlymelbourne.com.au/melb_index_test.php
If you go to this page a category list displays. What i need to know is how can i modify the script below so that when the user clicks on a category and goes to the sub-category page (same page) how can i get the first level category list (eg. Shopping, Visiting the City etc.) to display left of the sub-catergoy list?
main_index_test.php
<?
if(!$id) $id = 1;
$link = mysql_connect('localhost', '', '');
mysql_select_db('melb');
?>
<BODY bgcolor="#FFFFFF">
<?
function getParentID($childID){
$row = mysql_fetch_row(mysql_query("SELECT CatParent FROM categories WHERE CatID = $childID ORDER BY CatID"));
return $row[0];
}
if($id > 1){
$nextID = $id;
do{
$nextID = $ar[$count++] = getParentID($nextID);
} while($nextID > 1);
$ar = array_reverse($ar);
foreach($ar as $parent){
if($parent > 1){
$row = mysql_fetch_row(mysql_query("SELECT CatName FROM categories WHERE CatID = $parent"));
echo " - <a href=\"melb_index_test.php?id=$parent\">$row[0]</a>";
}
else {
include( "main_header.htm" );
echo "<table width=\"100%\" border=\"1\" bgcolor=\"#ffffff\"><tr><td><a href=\"melb_index_test.php\">Home</a>";
}
}
$row = mysql_fetch_row(mysql_query("SELECT CatName FROM categories WHERE CatID = $id"));
echo " - $row[0]</td></tr></table>";
//echo "<a href=\"melb_index_test.php?id=$id\">$row[0]</a>";
}
echo "<BR><BR>";
$row = mysql_fetch_row(mysql_query("SELECT COUNT() FROM categories WHERE CatParent = $id"));
if($row[0] > 0){
$result = mysql_query("SELECT FROM categories WHERE CatParent = $id ORDER BY CatID");
while($row = mysql_fetch_array($result)){
echo "<img height=\"11\" src=\"Melbourne, Victoria_files/arrow.gif\"> <a href=\"melb_index_test.php?id={$row['CatID']}\">{$row['CatName']}</a><br><br>\n";
}
} else {
$query = "SELECT * FROM categories WHERE CatID = $id";
$result = mysql_query($query);
while($row = mysql_fetch_array($result)){
echo "<img height=\"11\" src=\"Melbourne, Victoria_files/arrow.gif\"> <b>{$row['CatName']}</b><BR><BR>";
echo "{$row['Info']}<BR>";
echo '</blockquote>';
$urls = explode(", ", $row[url]);
for ($i = 0; $i < count($urls); $i++) {
echo "<a href=$urls[$i] target=\"_blank\">$urls[$i]</a><br>";
}
}
}
?>
</BODY>