I have a table in MySQL with the following data (In the Parent column, a 0 indicates that this is a root category and has no parent):
ID | TITLE | PARENT
1 | RACING | 0
2 | MARINE | 0
3 | DRAG RACING | 1
4 | DIRT RACING | 1
5 | TIMED RACE | 3
6 | BOATS | 2
I need a simple PHP function that will generate an HTML dropdown list like so:
<option value="2">MARINE</option>
<option value="6">MARINE-->BOATS</option>
<option value="1">RACING</option>
<option value="4">RACING-->DIRT RACING</option>
<option value="3">RACING-->DRAG RACING</option>
<option value="5">RACING-->DRAG RACING-->TIMED RACE</option>
Basically a tiered select box, with everything sorted alphebatically. Each option should list the parent, if there is one. I need this function NOW, so if you can provide it NOW, you'll get the project NOW. Simple as that.