0
     how to make multilevel menu like 
.A
   .B
      .C
      .D

      C & D is the sub-menu of B , 
      B is the sub-menu of A 
      A is main-menu 
3
Contributors
2
Replies
19
Views
2 Years
Discussion Span
Last Post by diafol
2

There have been many, many threads on this in the past. Perhaps searching this forum will help. However, yes you can get PHP to spit out the HTML required to build an MLM in the first place. As edbr states, you will need CSS and/or JS to make it work. There are some nice CSS-only MLMs that do not require any JS.

JorgeM's version is really cool:

https://www.daniweb.com/web-development/code/494380/creating-a-simple-css-navigation-menu

The ease of "nesting" or "levels" will depend upon your datastore. If you have a static menu, then you don't really need PHP at all. If you have a dynamic menu, e.g. updated via admin panel, then you probably do need PHP.

If you do not have a datastore (probably DB) yet, then you have a few options as to how to store the data. The two front-runners are 'adjacency list' model and the 'nested sets' model.

Adjacency, probably the easiest, is where you have a self-referencing parent_id column.
The nested sets, if far more elegant IMO, but probably not worth the hassle if your MLM isn't that complicated. If you are interested, then read this:

http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.