I have the table width structure like this:
record | color| status
--------------------
record1 | blue | x
record1 | blue | y
record2 | red | x
record3 | yellow | y
I want to count records grouping by 'color' and for each one count 'x' and 'y'. I want to get the results like this:
color=blue, quantity=2, x=1, y=1 color=red, quantity=1, x=1, y=0 color=yellow, quantity=1, x=0, y=1
My query:
SELECT color as clr,
count(record) as cnt
FROM table
WHERE status IN (x, y)
GROUP BY week(color)
I print results in php like this:
while ($row= mysql_fetch_assoc($query)){
echo "color=".$row['clr'].", quantity=".$row['cnt'].", x=".$row['cnt'][0].", y=".$row['cnt'][1];
}
So the problem is that my method of printing results in php does not work.