I have an app that users choose items and then it fills a table that has two columns in it: Category and Items. Its something like this:
Category | Items
-----------------
PET | Dog Food
HEALTH | Tooth Brush
PET | Cat Food
COLD FOOD | Steak
COLD FOOD | Eggs
In my select statement I order the data by Category then by Items and I am using a WHILE loop to drop the data into an array.
while($listItems = mysql_fetch_array($results))
{
$myArray[] = array("category" => $listItems["Category"],
"item" => $listItems["Name"]);
}
When I do a print_r($myArray); I get something like this:
Array ( [0] => Array ( [category] => Cold Food [item] => Steak )
[1] => Array ( [category] => Food [item] => Eggs )
[2] => Array ( [category] => Health [item] => Tooth Brush )
[3] => Array ( [category] => Pet [item] => Cat Food )
[4] => Array ( [category] => Pet [item] => Dog Food ) )
What I am wanting to do is output the data into a nested list something like this.
- Cold Food
- Steak
- Eggs
- Health
- Tooth Brush
- Pet
- Cat Food
- Dog Food
Any help is welcomed! Thanks!