PHP Zend 框架 - 多层菜单
在我的应用程序中,我想制作一个像这样的动态多层菜单
玩具1
==>子玩具1-a
==>子玩具1-b
玩具2
==>子玩具2-a
==>子玩具2-b
玩具3
==子玩具3-a
我在数据库中创建了 2 个名为parent的表-菜单包含Toy1,Toy2,Toy3,子菜单包含Sub toy1-a,Sub toy1-b及其所属的父级。我不知道如何检索数据库或算法来实现此目的。有人有解决办法吗?
In my application, i want to make a dynamic multi layer menu like this
Toy1
==>Sub toy1-a
==>Sub toy1-b
Toy2
==>Sub toy2-a
==>Sub toy2-b
Toy3
==Sub toy3-a
I have created 2 table in database called parent-Menu contain Toy1,Toy2,Toy3 and sub-Menu contain Sub toy1-a, Sub toy1-b and their father which it belongs. I don't know how to retrieve database or algorithm to make this. Anybody have solution ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议您只使用一张表,这将使您的程序变得非常容易。
为所有顶部菜单取 3 个字段 *menu_id* 、 *menu_text* 、 *parent_id* 取父 id 1。现在执行以下工作,
从表中检索所有数据。
并使用递归函数来放置菜单。
I can recommend you to use only one table, it will make your program very eaisy.
take 3 field *menu_id* , *menu_text* , *parent_id* for all top menu take parent id 1. now do the following work,
Retrieve all data from the table.
And use the recursive function to the place the menu.