0

I am thinking of what the best way is to store a given menu tree for a shop-like system. That includes a menu tree with multiple sub-levels and items that are assigned to those levels.

Special requirements: - Each level needs to include all items of the sub- and sub-n-levels - Each item (might!) be assigned to multiple levels

Short example:

[Category A]
  [Category A-A]
    - Product: Apple
    [Category A-A-A]
      - Product: Pear
[Category B]
  - Product: Salad
  - Product: Apple

Following ouputs: - Display root: The tree + all products shall be shown (1x Apple !, Pear and Salad) - Display Category A-A: The tree + Apple and Pear shall be shown - Display Category A-A-A: The tree + only Pear shall be shown

Any suggestions or hints to achieve that with help of PHP and MySQL?

4

2 回答 2

1

看一下:

http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/

http://en.wikipedia.org/wiki/Nested_set_model

(初读)

于 2011-06-15T07:00:55.017 回答
0

您应该为此使用可以从 PHP 代码生成的 javascript 树库。看下面的链接,你可以选择任何人。

http://www.queness.com/post/1138/10-javascriptcss-treeview-and-sitemap-plugins-and-tutorials

于 2011-06-15T06:59:16.100 回答