How do you count different values from same column

Hi,

I’ve a column called ‘status’ and three different values stored in it, including HIGH, MIDDLE and LOW. How do I count these different values and use them as strings like this one:


if ( $row['HIGH'] >= 10 && $row['request'] == 3 ) {
     // the process continued
} elseif ( BLAH BLAH BLAH ) {
     // continues BLAH BLAH BLAH
}

I’ve tried this method and it doesn’t work: http://www.randomsnippets.com/2008/10/05/how-to-count-values-with-mysql-queries/

i did not understand your code and what it’s supposed to be doing

the way to count the statuses using mysql is as follows:

SELECT status
     , COUNT(*) AS rows
  FROM daTable
GROUP
    BY status

this produces a result set that looks like this:

[B]status rows[/B]
HIGH   42
LOW     9
MIDDLE 37

Thanks, that’s what the result I wanted.

The table takes values from submit form and I want to process the user’s request after viewing a report.

But how do I use that 42 rows. Here’s my table stricture:


id      text_field     status      user_id     request

I should really change the request to action.
The main point is how many HIGH, LOW, MIDDLE statuses the user requested which needs to take an action? I set 1 = ‘not done yet’, 2 = ‘rejected’, 3 = ‘done’. The query request all fields but I only want to count status column so I cloud review the user’s request history.

Hope I make it clear.
Thanks,

UPDATE: It doesn’t work in the while loop.

possibly you want to add a WHERE clause …

SELECT status
     , COUNT(*) AS rows
  FROM daTable
 [COLOR="#FF0000"]WHERE request = 1 [/COLOR]
GROUP
    BY status

that would be a php problem, and this is the mysql forum

sorry, i don’t do php