Lets assume I have a table like this:
-> id | parent_id | name
-> 1 | 0 | Food
-> 2 | 1 | Salty
-> 3 | 1 | Sweet
-> 4 | 2 | Patty
-> 5 | 4 | Meat
-> 6 | 3 | Cupcake
-> 7 | 5 | Made on Oven
-> 8 | 5 | Fried
-> 9 | 6 | Chocolate
I wonder what kind of witchcraft i have to make in PHP to get an ordered result dinamically without knowing the ammount of sublevels that the list are going to have like this:
Food
- Salty
- - Patty
- - - Meat
- - - - Made on Oven
- - - - Fried
- Sweet
- - Cupcake
- - - Chocolate
Thank you!