分3次查询不行吗?或者一个循环查询,
a=array('及格','优秀','良好');
for($i=0;$i++;$i<3){
$query="select SUM(votes) AS total from chengji where chengji='$a[$i]'";
$result=mysql_db_query("oa",$query,$connect);
while($arr=mysql_fetch_array($result)){
?>
学生成绩为<?echo $a[$i] ?>的有<?php echo $arr['total']; ?>人
};
a=array('及格','优秀','良好');
for($i=0;$i++;$i<3){
$query="select SUM(votes) AS total from chengji where chengji='$a[$i]'";
$result=mysql_db_query("oa",$query,$connect);
while($arr=mysql_fetch_array($result)){
?>
学生成绩为<?echo $a[$i] ?>的有<?php echo $arr['total']; ?>人
};
SUM(case when chengji='及格' then votes else 0 end) AS total2,
SUM(case when chengji='优秀' then votes else 0 end) AS total3
from chengji
$query="select * from chengji";
$result=mysql_db_query("oa",$query,$connect);
$i = 0;
$j = 0;
while($arr=mysql_fetch_array($result)){
$chengji = $arr["chengji"];switch ($chengji) {
case "11";
$i++;
//echo $i;
break;
case "12";
$j++;
break;
} }
echo $i;
echo $j;
?>