kickassamd Posted March 19, 2008 Share Posted March 19, 2008 Im confused on storing a menu system with a parent \ child relationship in mySQL and how to retreive and display it. Example... MAIN---- ---- SUBITEM ---- SUBITEM MAIN---- ----- SUBITEM etc etc. Thanks guys! Quote Link to comment https://forums.phpfreaks.com/topic/96957-menu-system-with-mysql/ Share on other sites More sharing options...
dmccabe Posted March 19, 2008 Share Posted March 19, 2008 Sure you would have 2 tables? One with parent and one with child menus then have the display the parent manue and any child menu with the parent's ID? Something like: tbl_parent -pid -pname tble_child -cid -pid -name I am no tables expert but that is how I would approach it. Quote Link to comment https://forums.phpfreaks.com/topic/96957-menu-system-with-mysql/#findComment-496226 Share on other sites More sharing options...
kickassamd Posted March 19, 2008 Author Share Posted March 19, 2008 1 table id, label, link and parent id and order Quote Link to comment https://forums.phpfreaks.com/topic/96957-menu-system-with-mysql/#findComment-496241 Share on other sites More sharing options...
helbom Posted March 19, 2008 Share Posted March 19, 2008 tbl_menu -id -name -link -cid ------------------------------------ | id | name | link | cid | ------------------------------------ | 1 | home | home.php | 0 | | 2 | sub | hsub.php | 1 | | 3 | new | new.php | 0 | |4 | newsub| nsub.php | 2 | ------------------------------------ did it make any sense? Quote Link to comment https://forums.phpfreaks.com/topic/96957-menu-system-with-mysql/#findComment-496257 Share on other sites More sharing options...
kickassamd Posted March 19, 2008 Author Share Posted March 19, 2008 Yeah i have the db structure... Just lost on the PHP end. Quote Link to comment https://forums.phpfreaks.com/topic/96957-menu-system-with-mysql/#findComment-496268 Share on other sites More sharing options...
helbom Posted March 19, 2008 Share Posted March 19, 2008 ahh ok... first output the main menu.. then pull out the child id's that's linked to the main menu id then continue the looping trough everything Quote Link to comment https://forums.phpfreaks.com/topic/96957-menu-system-with-mysql/#findComment-496273 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.