[eluser]Bigil Michael[/eluser]
I would like to create a menu like this from a single table
Code:
two wheeler
four wheeler
jeep
cars
Audi
BMW
Benz
Code:
I have created table with name menus, like this
id parent menu_name
1 0 two wheeler
2 0 four wheeler
3 1 cars
4 1 jeep
5 3 Audi
6 3 BMW
7 3 Benz
i wrote the query like this
Code:
SELECT p.menu_name as menu,d.menu_name as sub_menu,f.menu_name as sub_sub_menu FROM menus AS p join menus d on d.parent = p.id join menus f on f.parent = d.id
and tried to print the result in a normal way
Code:
<?php
foreach($list_menu as $row) {
echo $row->menu.'<br/ >';
echo ' '.$row->sub_menu.'<br/ >';
echo ' '.$row->sub_sub_menu.'<br/ >';
} ?>
got the result like this
Code:
four weeler
cars
Audi
four weeler
cars
BMW
four weeler
cars
benz
here two wheeler, jeep etc are missing and not in proper format.
can anyone help me to solve this issue....