I’m having a hard time getting this menu to work properly.
function writeMenu(){ (sorry, it wouldn’t format properly)
echo "<div id=\"menu\">" <ul id=\"top-link\">";
m("top", "n"); echo "</ul></div>";
function m($parent,$issub){
$parentQ = "select * from cdi_menu";//gets menu items from menu table
$parentResult = mysql_query($parentQ); //runs menu item query and obtains result
while ($link = mysql_fetch_assoc($parentResult)) {//for each line in the result do the folowing:
if($parent==$link['PARENT']){//if the next link belongs to this menu item
echo "\n <li><a href=\"".$link['LINK']."\">".$link['DISPLAY']."</a></li>";
if($issub=="n" && $link['HASCHILD']=="y"){//if this menu item is a top menu item
echo "\n <li id=\"sub-link\"><ul>";
m($link['ID'], $links, "y");
echo "\n </ul></li>";
}
}
}
}
echo writeMenu();
What I’m trying to do is make it where I can hide the ‘sub-link’ IDs (I would use classes, but javascript doesn’t seem to edit class styles, just IDs). The sub-link items would show when over a parent item.
top refers to the top elements, and ID refers to the unique id in database.
Thanks, sorry if it’s confusing.
Your function has only 2 parameters but You call it with 3 inside
$links is unnecessary.
It would be better if You modify query to look like this
so You don’t need first if statement and You will not fetching all rows multiple times for each menu/submenu.