Once I run my query, joining several columns together, I get results like this:
id item category
1 item 1 A
1 item 1 B
1 item 1 C
2 item 2 A
2 item 2 D
3 item 3 B
3 item 3 E
I've got a while loop that will output each row:.
while($results = mysql_fetch_array($raw_results)) {
echo $results['item'].<br>;
echo "Category: ".$results['category'];
}
and it's giving this:
<div>
Item 1
Category: A
</div>
<div>
Item 1
Category: B
</div>
and so on, but what I need to do is combine all the values for each ID into one space, so the results look like:
<div>
Item 1
Category: A, B, C
</div>
<div>
Item 2
Category: A, D
</div>
<div>
Item 3
Category: B, E
</div>
What's the best way to do this? Should I create another array with the rows for each ID, and loop through that (and how would I set up the array?) Or is there something else?