I have a db that have this kind of structure:
name|color
paul|blue
mary|red
paul|green
joe |yellow
paul|purple
mary|orange
paul|white
etc |etc
What am I trying to achieve here is to list the colors associated with a name, something like this:
paul=blue,green,purple,white
mary=red,orange
joe=yellow
I was checking some examples and found this:
$query="SELECT * FROM mytable order by name";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)){
echo $row['name']. " - ". $row['color'];
echo "<br />";
}
To be honest I just don't know how to go from this to what an I trying to achieve. How can I create a condition that will list all the color associated with one name and then jump to the next and so on?
group byfor grouping by name.