Hi I need help completing a parent and child menu structure.
I can successfully display all of the parent items and even the children to that specific parent. I have even got the CSS applied to the menu, the problem is that when I click onto one of the children the parent does not remain open.
Please any advice as I think I am close to getting this to work.
I can successfully display all of the parent items and even the children to that specific parent. I have even got the CSS applied to the menu, the problem is that when I click onto one of the children the parent does not remain open.
Code:
$host = "localhost";
$dbuser = "user";
$dbpassword = "pass";
$database = "dev-connect";
$link = mysql_connect($host,$dbuser,$dbpassword);
$db_selected = mysql_select_db($database);
if (!$db_selected) {
die ('Can\'t select database : ' . mysql_error());
}
$getitemid = explode("Itemid=",$url);
$Itemid = $getitemid[1];
echo '<table cellpadding="0" cellspacing="0" class="moduletabletestmenu"><tr><td><table width="100%" border="0" cellpadding="0" cellspacing="0">';
$mainmenu = mysql_query("select * from mos_menu where menutype = 'mainmenu' and published = '1' and parent = '0' order by ordering asc");
while($gotmainmenu = mysql_fetch_array($mainmenu))
{
echo "<tr align='left'><td><a href='$gotmainmenu[3]&Itemid=$gotmainmenu[0]' class='mainlevelmark' "; if ($Itemid == $gotmainmenu[0]){echo "id='active_menumark'";} echo ">$gotmainmenu[2]</a>";
$submenu = mysql_query("select * from mos_menu where menutype = 'mainmenu' and published = '1' and parent = '$gotmainmenu[0]' order by ordering asc");
while($gotsubmenu = mysql_fetch_array($submenu))
{
if ($Itemid == $gotsubmenu[6])
{
echo "<div style='padding-left: 4px'><a href='$gotsubmenu[3]&Itemid=$gotsubmenu[0]' class='sublevelmark' "; if ($Itemid == $gotsubmenu[0]){echo "id='active_menumark'";} echo ">$gotsubmenu[2]</a></div>";
}
}
echo"</td></tr>";
}
echo '</table></td></tr></table>';
Please any advice as I think I am close to getting this to work.