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
- Marvel
- -Spiderman
- -Ironman
- -Thor
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?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…