时间:2021-07-01 10:21:17 帮助过:45人阅读
SELECT `chengji`,count(*) FROM `table` GROUP BY `chengji`
$sql = SELECT `chengji`,count(*) AS count FROM `table` GROUP BY `chengji`;可以得到类似这样的数组
$rs = mysql_query($sql);
while($row = mysql_fetch_assoc($rs)) {
$res[$row['chengji']] = $row['count'];
}
print_r($res);
Array
(
[及格] => 4
[不及格] => 1
[良好] => 3
)
$res[''] = '数量';
$head = array('', '不及格', '及格', '良好');
echo '
' . join(' | ', $head) . ' |
---|---|
' . (isset($res[$v]) ? $res[$v] : '') . ' | ';
date_default_timezone_set("PRC");
echo "当前月份是".date("m")."\n";
echo "本月初日期是".date("m")."-01\n";
echo "本月未日期是".date("m")."-".date("t")."\n";
?>