brob Posted October 6, 2006 Share Posted October 6, 2006 Hi can anyone help.here is the code for the menu [code]$host = "localhost";$dbuser = "un";$dbpassword = "pass";$database = "dev-cwc";$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>"; $getlevel = mysql_query("select * from mos_menu where id = '$Itemid'"); $gotlevel = mysql_fetch_row($getlevel); #echo "$gotlevel[6]<br>"; $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)) { 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>';[/code]and here is the mysql table [code]Field Type Null Defaultid int(11) No menutype varchar(25) Yes NULLname varchar(100) Yes NULLlink text Yes NULLtype varchar(50) No published tinyint(1) No 0parent int(11) No 0componentid int(11) No 0sublevel int(11) Yes 0ordering int(11) Yes 0checked_out int(11) No 0checked_out_time datetime No 0000-00-00 00:00:00pollid int(11) No 0browserNav tinyint(4) Yes 0access tinyint(3) No 0utaccess tinyint(3) No 0params text No [/code]I have got the main level to work correctly and it will show the sub menu's, but when you click on the sub menu it doesn't keep the top level open to show the sub level anymore.This isn't a css issue its something to do with the second while loop.Please I have a mental block and can't figure it out.Please help Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.