我想制作菜单,分层数据类别。我可以在数组中提取,但我必须生成菜单。这就是我所做的:
Array (
[17] => Array (
[cat_id] => 17,
[section_left] => 200,
[section_right] => 211,
[section_level] => 1,
[section_name] => Bauturi,
[nflag] => 1 ),
[22] => Array (
[cat_id] => 22,
[section_left] => 201,
[section_right] => 204,
[section_level] => 2,
[section_name] => Bere,
[nlag] => 1 ),
[32] => Array (
[cat_id] => 32,
[section_left] => 202,
[section_right] => 203,
[section_level] => 3,
[section_name] => Fara Alool,
[nflag] => 0 ),
[31] => Array (
[cat_id] => 31,
[section_left] => 205,
[section_right] => 210,
[section_level] => 2,
[section_name] => Cu Alcol,
[nflag] => 1 ),
[34] => Array (
[cat_id] => 34,
[section_left] => 206,
[section_right] => 207,
[section_level] => 3,
[section_name] => Tuborg,
[nflag] => 0 ),
[58] => Array (
[cat_id] => 58
[section_left] => 208
[section_right] => 209
[section_level] => 3
[section_name] => uuuu5
[nflag] => 0)
)
Array (
[18] => Array (
[cat_id] => 18,
[section_left] => 212,
[section_right] => 219,
[section_level] => 1,
[section_name] => Patiserie,
[nflag] => 1 ),
[23] => Array (
[cat_id] => 23,
[section_left] => 213,
[section_right] => 214,
[section_level] => 2,
[section_name] => Prajituri,
[nflag] => 0 ),
[24] => Array (
[cat_id] => 24,
[section_left] => 215,
[section_right] => 218,
[section_level] => 2,
[section_name] => Ciocolata,
[nflag] => 1 ),
[33] => Array (
[cat_id] => 33,
[section_left] => 216,
[section_right] => 217,
[section_level] => 3,
[section_name] => Beks,
[nflg] => 0 )
)
.
.
.
使用此代码我获取该菜单,但我有一个错误。我必须得到所有的孩子并为每个孩子制作一个子菜单,例如第一项,
BAUTURI 1
--BERE 2
-----Fara Alcool 3
--Cu alcool
-----Tuborg 3
-----uuuuu5 3
我的问题是,如何在数据库中为项目构建该foreach以在页面中正确显示?