前面已经写过如果只做动态柱状图,其实原理还是很简单的。今天,因为昨天下午有新的需求,今天上午又修改了一番,并将数据根据编号不同分割显示在表中。 下面把代码粘出来,方便以后自己查看,思路只是一时的火花,今天我想出来这么做,不一定下次还能想得到
前面已经写过如果只做动态柱状图,其实原理还是很简单的。今天,因为昨天下午有新的需求,今天上午又修改了一番,并将数据根据编号不同分割显示在表中。
下面把代码粘出来,方便以后自己查看,思路只是一时的火花,今天我想出来这么做,不一定下次还能想得到,也不用费劲的去想,所以写成笔记是比较好的形式。
<?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_datequery($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); ?> <meta charset="utf-8"> <style> div { background-color: #669900; width: 50px; } #div1 { height: 200px; } #table td { } </style> <script type="text/javascript" src="../../../js/jquery-1.7.2.min.js"></script> <h3 id="近一个月总的情况">近一个月总的情况</h3>
总计 |
一审通过 |
二审通过 |
审核通过 |
近一个月每个人的情况
总分 | "; $trStr_total_number = "||||
总数量 | "; $trStr_average_score = "||||
平均分 | "; $resultStr = ""; foreach ($newRow as $key => $value) { // echo $key."=>".$value."" . $value2 . " | "; // 表头 } elseif ($key2 == 'total_score') { $value2 = sprintf("%.2f", $value2); //保留2位小数 $trStr_total_score .= "" . $value2 . " | "; $x += $value2; } elseif ($key2 == 'total_number') { $trStr_total_number .= "" . $value2 . " | "; $x /= $value2; } } $x = sprintf("%.2f",$x); $trStr_average_score .= "" . $x . " | "; } echo "
---|
为了更加方便的了解代码的效果,截个图吧

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Atom editor mac version download
The most popular open source editor

SublimeText3 Linux new version
SublimeText3 Linux latest version

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),