i have a mysql table.
ID Name ParentID
1 Section 1 0
2 Section 2 0
3 Section 2a 2
4 Section 2b 2
5 Section 2ba 4
Idea being that this will lead to a practically unlimited breadcrumbing....
anyway - the question i have is looping this table.
i want to get this result in a dropdown box
value label
1 section 1
2 section 2
3 section 2 -> section 2a
4 section 2 -> section 2b
5 section 2 -> section 2b -> section 2ba
now, i cant be sure how many levels of sections there will be, otherwise id do this :
SELECT * FROM Sections WHERE Parent = '0' // get the top level first
while (next_record()){
$sectionid = field(ID)
$sectionname = field(Name)
SELECT * FROM Sections WHERE Parent = '$sectionid'
while (next_record()){
etc....
};
};
..yes i know that this isnt the correct syntax - just to give you an idea. this would only cater for a two level system, not an unlimited system, which is required.
i need to automatically loop all possible levels.
ideas on a postcard please....