Everyone: I need some help in my current project which is using PHP and MYSQL. I have a database that includes a lot of user information.
For example:
report year=2012
Name:Chan Tai Man
Age:20
School: Science school
school period:2011-2015
Chinese:1
English:2
overall grading:B
The thing I want to do is sorting by several priority for:
Since I only use the report which is the current year(2012), first check if it is the current year;
Check whether it's the period over 3, if yes,continue;
Then sorting ASC for the overall grading; --->if the overall grading is the same,then sort with the English; --->if the English is also the same,then sort with the Chinese;
Show the table with all information after sorting by the above priority;
Now,I can show the table of information with the current year and check whether the period is above 3 but I am confuse how can I compare the data from the previous sorting but not from the table?
eg.
$sorting_year=mysql_query("SELECT * FROM $tbl_name where year = $current_year");
( want to continue sort the data which conform the above condition ....)
Thank you~~
Thank you for everyone, it can sort the data which conform the above conditions.
However, the remaining data which did not conform the above conditions,I also want to show them in the table but put all these data in the last of the table and group by the school.How can I select them and sort to be the last?
example: (Lastly all the data will be shown on the table)
1.John period>3 B A A 2011 //since second A is higher than B
2.Betty period>3 B B A 2011 //period>3 and 2011
3.Louis (period<3) A A A 2011 //period<3 but is 2011
4.Mary period>3 A A A (2010) //2010=[ although period>3
check whether is the period over 3:school periodis a single field that contains a string that has to be evaluated? So the querySELECT `school period` from Foowould return "2011-2015" for your example record?