How to build unlimited level of menu through PHP and mysql

前端 未结 8 1518
心在旅途
心在旅途 2020-11-29 01:05

Well, to build my menu my menu I use a db similar structure like this

  2  Services                  0
  3  Photo Gallery             0
  4  Home                         


        
8条回答
  •  心在旅途
    2020-11-29 01:17

    http://pastebin.com/ariBn3pE

    You need to use recursion, but my approach it's different, I created a class to handle each menu individually, then queried for results and group each elements in their individual object according to their parents, organized that by levels, and then merge all the objects into one... check the pastebin for the full code

提交回复
热议问题