时间:2021-07-01 10:21:17 帮助过:3人阅读
SELECT `chengji`,count(*) FROM `table` GROUP BY `chengji`
$sql = SELECT `chengji`,count(*) AS count FROM `table` GROUP BY `chengji`
在php中把mysql_query($sql);的结果打印出来看看
$sql = SELECT `chengji`,count(*) AS count FROM `table` GROUP BY `chengji`
在php中把mysql_query($sql);的结果打印出来看看
结果是Resource id #5
$sql = SELECT `chengji`,count(*) AS count FROM `table` GROUP BY `chengji`
在php中把mysql_query($sql);的结果打印出来看看
用mysql_fetch_array
结果为Array ( [0] => 及格 [type] => 及格 [1] => 4 [count] => 4 )
用mysql_fetch_array
结果为Array ( [0] => 及格 [type] => 及格 [1] => 4 [count] => 4 )
while($row = mysql_fetch_array()){}
用mysql_fetch_array
结果为Array ( [0] => 及格 [type] => 及格 [1] => 4 [count] => 4 )
while($row = mysql_fetch_array()){}
我明白了 这样和数据库中查询出的格式的一样的
可是我想在页面中做一个固定的table 和数据库中的格式不一样
$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] : '') . ' | ';echo '
再问个小问题 怎么用date() 获取 当月 月初 和 月末 日期
再问个小问题 怎么用date() 获取 当月 月初 和 月末 日期