Hi all,
How can i make it so that when the navigation system reaches the last category it shows the details for this topic from a different table. Would this even be the best way to do it?
At the moment it inserts the data from the categories table but i want a seperate table named businesses just for their details. (name, address, url, info etc.)
Any ideas?
The script is below:
<?
if(!$id) $id = 1;
$link = mysql_connect('localhost', '', '');
mysql_select_db('melb');
?>
<body>
<?
//echo "<a href=\"melb_index.php\">Home</a>";
?>
<?
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.php?id=$parent\">$row[0]</a>";
}
else {
echo "<table width=\"100%\" border=\"1\" bgcolor=\"#ffffff\"><tr><td><a href=\"melb_index.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.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.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><a href=\"{$row['url']}\" target=\"_blank\">{$row['url']}</a><BR><BR>";
echo "{$row['Info']}<BR>";
echo '</blockquote>';
}
}
?>
</body>