I will try my best to explain what I am looking for.
Let's say for argument's sake that I have a table in my database that has the properties ID
, Item
, Category
...
the table is populated as so:
================================
|ID| |Item | Category |
================================
| 1 | Batman | DC |
| 2 | Superman | DC |
| 3 | Aquaman | DC |
| 4 | Spiderman| Marvel |
| 5 | Ironman | Marvel |
| 6 | Thor | Marvel |
================================
Now, I want to create a dropdownlist with this information... but seperated by the category..
So it would look like this:
- DC
- -Batman
- -Superman
- -Aquaman
- -Batman
- Marvel
- -Spiderman
- -Ironman
- -Thor
- -Spiderman
Now it doesn't need to be as formatted as shown above but just a simple nested list with the emphasis on the Category
How would I iterate through the table and each time the Category
changes to print that Category text once then print the Item
's that correspond with that Category
underneath it?