Is there a way to get a distinct value from a table and echo it as a id for a div tag and still have the rest of the values echo too?
Say I have a table with these values:
category
item
With 3 categories each having 3 items
I'd like category to be distinct and all the items in that category to be listed in the divs like this:
<div id="category1">
item1
item2
item3
</div>
<div id="category2">
item1
item2
item3
</div>
<div id="category3">
item1
item2
item3
</div>
I use this to get the div array:
$result = mysql_query("SELECT DISTINCT category FROM $mysql_table ORDER BY category");
while($row = mysql_fetch_array($result)) {
echo "<div id=\"".$row['category']."\">
";
echo "".$row['category']."";
echo "
</div>
";
But I would like to get the rest of the values to list the items for each category where echo "".$row.""; is now.
Kind of hard to explain. Hope this makes sense?