最近我做了一个博客即编程教程博客
你能给我一个创建这样的菜单导航的逻辑吗:
Java >> Frameworks >> Struts2
我必须为此使用什么逻辑?我很困惑地想,这种逻辑是否发生在 SQL 查询中?
我正在使用:Codeigniter,php,我的 sql
我的数据库结构是这样的:
Table: menu
---------------
id PK(primary key)
menu_name .....
content longtext
parent_id int(key to id) Foreign key
这是存储在表中的数据的示例:
Example
----------------
id | menu_name | content | parent_id
----------------------------------------
1 | main 1 | this is main menu 1 | 0 <-- First level menu
2 | main 2 | this is main menu 2 | 0 <-- First level menu
3 | submenu 1 | this is main menu 1's first submenu's item 1 | 1 <-- Second level menu
4 | submenu 1 | this is main menu 1's first submenu's item 2 | 1 <-- Second level menu
5 | submenu 2 | this is main menu 2's first submenu's item 1 | 2 <-- Second level menu
6 | submenu 1-1 | this is submenu 1's first submenu's item 1 | 3 <-- Third level menu
7 | submenu 1-2 | this is submenu 1's first submenu's item 2 | 3 <-- Third level menu