PHP实现动态柱状图改进版
本文实例分析了PHP实现动态柱状图的改进版。分享给大家供大家参考。具体分析如下:前面已经写过如果只做动态柱状图的情况,其实原理还是很简单的。因为昨天下午有新的需求,今天上午又修改了一番,并将数据根据编号不同分割显示在表中。
下面把代码粘出来,方便以后自己查看,思路只是一时的火花,今天我想出来这么做,不一定下次还能想得到,也不用费劲的去想,所以写成笔记是比较好的形式。
<?php // 计算上一个月的今天 function last_month_today($time) { $last_month_time = mktime(date("G", $time), date("i", $time), date("s", $time), date("n", $time), 0, date("Y", $time)); $last_month_t = date("t", $last_month_time); if ($last_month_t < date("j", $time)) { return date("Y-m-t H:i:s", $last_month_time); } return date(date("Y-m", $last_month_time) . "-d", $time); } ?> <?php include dirname(dirname(dirname(__FILE__))) . '/config.php'; $endDate = date('Y-m-d'); $date = strtotime($endDate); $beginDate = last_month_today($date); $sql = 'select count(*) from newpro where p_date>\'' . $beginDate . '\' and p_date<\'' . $endDate . '\''; $d = db()->query($sql)->fetch(PDO::FETCH_NUM); $sql2 = $sql . ' and is_pa_check_first=1 and is_pa_check_second=1 and is_pa_check_third=1'; $d2 = db()->query($sql2)->fetch(PDO::FETCH_NUM); $sql3 = $sql . ' and is_pa_check_first=1'; $d3 = db()->query($sql3)->fetch(PDO::FETCH_NUM); $sql4 = $sql . ' and is_pa_check_first=1 and is_pa_check_second=1'; $d4 = db()->query($sql4)->fetch(PDO::FETCH_NUM); // 查询每个人通过审核的情况: $sqlab = 'select d_m,sum(sroce) as total_score,count(d_m) as total_number from newpro where is_pa_check_first=1 and is_pa_check_second=1 and is_pa_check_third =1 group by d_m'; $row = db()->query($sqlab)->fetchAll(PDO::FETCH_ASSOC); ?>
PHP之友评论