简体   繁体   中英

show category and subcategories in a tree menu using codeigniter

I want to show categories and subcategories like a tree menu:

Category

  • Subcategory
  • Subcategory 2

Category 2

  • Subcategory
  • Subcategory 2

my database contains 3 colomns:

categoryId, categoryName, categoryParentId

I really don't have an idea how to do this?! Can somebody help me?! I found some codes on the net, but I couldn't make them work

The best way to make such a structure would be to implement either an Adjacency List model or Nested Set model . You can read more about them in this excellent article by Mike Hillyer.

Of course, you can always come up with a home-made solution, but in my experience, they often don't come up as good, effective and flexible as the two mentioned above.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM