-2

可能重复:
PHP / MySQL 构建树菜单

我需要在两级构建菜单之间获取数据。

ID | Parent    | Name    | 
 1 | 0         | Cat1    | 
 2 | 1         | SubCat1 | 
 3 | 0         | Cat2    | 
 4 | 3         | SubCat2 | 
 5 | 4         | SubCat3 | 
 6 | 3         | SubCat4 | 
 7 | 3         | SubCat5 |


Level 1: Cat1 and Cat2
Level 2: SubCat1, SubCat2 and Subcat4
Level 3: SubCat3 and SubCat5
  • 第一类
    • 子类 1
  • 类别 2
    • 子类 2
      • 子类 3
      • 子类 5
    • 子类 4

我想要 2 级和 3 级菜单列出数据。我如何在 2,3 行之间调用?

4

1 回答 1

1

The correct name here for this data is an adjacent list hierarchy

There is a guide on this website to produce this in MySQL

http://kod34fr33.wordpress.com/2008/05/06/adjacency-list-tree-on-mysql/

于 2012-11-16T15:39:12.757 回答