homepage Welcome to WebmasterWorld Guest from 54.167.179.48
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Database Menu into array
Marked

5+ Year Member



 
Msg#: 4084117 posted 1:51 am on Feb 21, 2010 (gmt 0)

Hi all,

I am currently trying to further my website-forum integration by recreating the menu(generated from the database) in my forums.

To do this, I am trying to put all the menus and submenus into an array. The tricky part is getting the submenus into the array, which I am lost with.

To make things clearer, here is an image with some of the rows:
<snip>

So I need to get the menus into an array(using a query similar to the one in the image), with similar levels. The parent field determines their levels. However, I also need to store the ID for each menu. I'd like the array to display something like this:
Level1
--Level2
--Level2
--Level2
Level1
--Level2
--Level2
--Level2
-----level3
-----level3
-----level3

Sorry if this post is confusing,

Thanks in advance,
Mark.

[edited by: eelixduppy at 1:56 am (utc) on Feb 21, 2010]
[edit reason] removed url [/edit]

 

Marked

5+ Year Member



 
Msg#: 4084117 posted 3:04 am on Feb 21, 2010 (gmt 0)

Sorry for the double post, the edit is not working.

It seems a mod removed my image. The table structure is as follows

id| name| parent|
-----------------------
1 Menu 1 0
2 Menu 2 0
3 Menu 3 0
4 Menu 4 1
5 Menu 5 1
6 Menu 6 4
7 Menu 7 4 <-notice this is a sub menu of a submenu

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved