johnrb87 Posted January 6, 2011 Share Posted January 6, 2011 Hi all I have a menu function which basically produces a menu which looks like Products Apple iMac iPod iPhone Microsoft Windows Office and the code I use is; THE FUNCTION function menu($parentID, $mymenu) { $html = ""; if (isset($mymenu['parentID'][$parentID])) { $html .= " <ul>\n"; foreach ($mymenu['parentID'][$parentID] as $menu_id) { if(!isset($mymenu['parentID'][$menu_id])) { $html .= "<li>\n <a href='/".$mymenu['menu_item'][$menu_id]['url']."'>".$mymenu['menu_item'][$menu_id]['value']."</a>\n</li>"; } if(isset($mymenu['parentID'][$menu_id])) { $html .= "<li>\n <a href='/".$mymenu['menu_item'][$menu_id]['url']."'>".$mymenu['menu_item'][$menu_id]['value']."</a>"; $html .= menu($menu_id, $mymenu); $html .= "</li>"; } } $html .= "</ul>"; } return $html; } CREATE MENU CODE $result = mysql_query("SELECT id, value, url, parentID FROM menu WHERE active = 1 AND deleted = 1 ORDER BY position ASC"); $mymenu = array('menu_item' => array(),'parentID' => array()); while ($menu_item = mysql_fetch_assoc($result)) { $mymenu['menu_item'][$menu_item['id']] = $menu_item; $mymenu['parentID'][$menu_item['parentID']][] = $menu_item['id']; } echo menu(0, $mymenu); The problem I have is the URLS, at the moment the menu URLS are outputted as Products - http://localhost/Products Apple - http://localhost/Apple iMac - http://localhost/iMac iPod - http://localhost/iPod But I need to alter my function so that URLS are outputted as Products - http://localhost/Products Apple - http://localhost/Products/Apple iMac - http://localhost/Products/Apple/iMac iPod - http://localhost/Products/Apple/iPod Is this at all possible? Thanks very much everyone John Link to comment https://forums.phpfreaks.com/topic/223583-multi-level-menu-help/ Share on other sites More sharing options...
johnrb87 Posted January 6, 2011 Author Share Posted January 6, 2011 Hi all Any ideas? Been trying to figure this out all day without any luck Thanks Link to comment https://forums.phpfreaks.com/topic/223583-multi-level-menu-help/#findComment-1155773 Share on other sites More sharing options...
johnrb87 Posted January 8, 2011 Author Share Posted January 8, 2011 can anyone help please? Link to comment https://forums.phpfreaks.com/topic/223583-multi-level-menu-help/#findComment-1156506 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.