Я хочу сделать меню, иерархическую категорию данных. Я могу извлечь в массиве, но я должен создать меню. Вот что я сделал:
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 так, чтобы элемент в БД правильно отображался на странице?
Задача ещё не решена.
Других решений пока нет …