I am having the most difficult time outputting information from my database in the format I need.
My database contains many rows with this information:
Language, Speak, Read, Write
French, 0, 3, 8
French, 2, 2, 8
French, 3, 2, 9
French, 0, 4, 4
Spanish, 7, 3, 8
Spanish, 0, 0, 1
...
Basically, the Language row contains the name of the language, with various values for different language skills on a scale between 0 and 10.
I'm trying to generate a report with grouped skills using a scale:
If the value is 0, I need that to equal NONE
If the value is between 1 and 4, I need that to equal GOOD
If the value is between 5 and 7, I need that to equal PROFICIENT
If the value is between 8 and 10, I need that to equal FLUENT
The output I'm looking for is in this format:
Language/SPEAK/READ/WRITE/COUNT
French/NONE/GOOD/FLUENT/1
French/GOOD/GOOD/FLUENT/2
French/NONE/GOOD/GOOD/1
Spanish/PROFICIENT/GOOD/FLUENT/1
Spanish/NONE/NONE/GOOD/1
I'm starting off with:
$result=mysql_query("SELECT *, COUNT(*) AS count FROM database GROUP BY language");
But beyond that I don't know. I can group them at the beginning, but basically I need to group ranges of numbers, not the actual numbers. If I convert the numbers after I select them using PHP, then I don't know what to do with it.
Any help is appreciated. Thanks.