I have a category table in mysql like that:
id (unique id of category)
pid (parent id of category, if 0 that means it is a parent category)
title (title of category)
Now from this table I want to display records in tree form (bcoz there may be as many levels as user wants)
Top Category
– Child Category
– Child Category
— Grand Child Category
— Grand Child Category
Top Category
How can I iterate through this category structure? Bcoz I cannot write many whiles inside whiles e.g.
while(){
while(){
while(){
AND SO ON …
}
}
}