I'm trying to create a system of menus for a website where you'll be able to create menus with the option of submenus. In my mysql 'menu_item' table, there's a 'hierarchy' column which will hold either a 0 if it's a topl-evel menu, or the id of the menu item under which it's located within the menu hierarchy. Now, what I'm trying to do is to come up with an SQL query that will return me an array that will already have the order of it taken care of in such a way that after each row, it will lay out all the rows that are under it heirarchichly. For example, if I have this menu:
menu1 - menu1.1, menu1.2 menu2 - menu 2.1, menu 2.2 menu 3 - menu 3.1
the result should be like this:
menu 1 menu 1.1 menu 1.2 menu 2 menu 2.1
and so on.
I can't put my mind into how to go about it. Is this even possible to do in MySQL, or am I just going to have to return the entire list of menu items and order them in PHP?
Thanks.