Trying to solve a phpmysql array problem.
Let's say I have a table in mysql format
Column1 Column2
dog brown
cat white
cat black
cat mixed
pig black
pig brown
What kind of (query, array function, loop, etc...) should I use to produce an html output like this:
1. column1:dog column2:brown
2. column1:cat column2: white, black,mixed
3. column1: pig column2: black, brown
Off the top of my head, untested:
$query = "select column1, column2 from $table";
$result = mysql_query($query, $mysql_connection) or [some kind of error handling];
while ($row = mysql_fetch_assoc($result)) {
$array[$row['column1'][] = $row['column2'];
}
now $array is: [dog] => array('brown') [cat] => array('white', 'black', 'mixed')
That should be easy to output in the desired way.
JP
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]