OceanIdiot Posted July 1, 2010 Share Posted July 1, 2010 I'm trying to make a dynamic menu. It goes pretty well, but I'm stuck now. If every headmenu has one submenu, every thing is okey, but if they have 2+ submenus then the head menu will be echoed once for every submenu.. I know why (in the same while loop) but I just do not know how to solve :/ Here's my code: <?php include('../config.php'); $sql_submenu = mysql_query("SELECT `mm_submenu`.`name` AS `submenu_name`, `mm_submenu`.`headmenu`, `mm_submenu`.`link`, `mm_submenu`.`order`, `mm_headmenu`.`name` AS `headmenu_name`, `mm_headmenu`.`alias`, `mm_headmenu`.`order` FROM `mm_submenu`, `mm_headmenu` WHERE ( `mm_headmenu`.`alias` = `mm_submenu`.`headmenu` ) ORDER BY `mm_headmenu`.`order`, `mm_submenu`.`order`") or die(mysql_error()); while($row_submenu = mysql_fetch_array($sql_submenu, MYSQL_ASSOC)) { echo($row_submenu['headmenu_name']. "<br />"); echo(" ". $row_submenu['submenu_name']. "<br />"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/206411-dynamic-menu-error/ Share on other sites More sharing options...
PFMaBiSmAd Posted July 1, 2010 Share Posted July 1, 2010 You would need to use logic similar to that found in this post - http://www.phpfreaks.com/forums/index.php/topic,302761.msg1432493.html#msg1432493 Quote Link to comment https://forums.phpfreaks.com/topic/206411-dynamic-menu-error/#findComment-1079783 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.