PHP/MySQL - building a nav menu hierarchy

前端 未结 5 589
予麋鹿
予麋鹿 2021-01-01 05:24

So the final menu will look something like this:

Item B
    Item B-1
        Item B-1-2
        Item B-1-1
Item A
    SubItem A-1
    SubItem A-2
Item C
         


        
5条回答
  •  臣服心动
    2021-01-01 05:45

    The way your storing hierarchical data isn't as efficient as you might want. I read the article Managing Hierarchical Data in MySQL a few years ago and have since found it as the best solution to managing hierarchy based data in SQL. Next best benefit is that I believe you can grab the entire tree with one query.

提交回复
热议问题