PHP動態(tài)柱狀圖實現(xiàn)方法
更新時間:2015年03月30日 09:02:30 作者:詩未冷
這篇文章主要介紹了PHP動態(tài)柱狀圖實現(xiàn)方法,實例分析了php結(jié)合HTML元素實現(xiàn)動態(tài)柱狀圖的技巧,非常具有實用價值,需要的朋友可以參考下
本文實例講述了PHP動態(tài)柱狀圖實現(xiàn)方法。分享給大家供大家參考。具體分析如下:
1.需求
查詢最近一個月的數(shù)據(jù)總條數(shù)和審核通過的條數(shù),做成柱狀圖
2.實現(xiàn)代碼:
<!DOCTYPE html>
<?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);
//查詢最近一個月的總的數(shù)據(jù)條數(shù)
$sql = 'select count(*) from newpro where p_date>\''.$beginDate.'\' and p_date<\''.$endDate.'\'';
//$sql = "select count(*) from newpro where p_date>'$beginDate' and p_date <'$endDate'";//這條語句也可以
$d = db()->query($sql)->fetch(PDO::FETCH_NUM);
//echo "總的數(shù)據(jù)條數(shù):".$d[0];
//查詢審核通過的數(shù)據(jù)條數(shù)
$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);
//echo "審核通過的數(shù)據(jù)條數(shù):".$d2[0];
//查詢一次審核通過的條數(shù)
$sql3=$sql.' and is_pa_check_first=1';
$d3 = db()->query($sql3)->fetch(PDO::FETCH_NUM);
//查詢二次審核通過的條數(shù)
$sql4=$sql.' and is_pa_check_first=1 and is_pa_check_second=1';
$d4 = db()->query($sql4)->fetch(PDO::FETCH_NUM);
?>
<html>
<head>
<meta charset="utf-8"/>
<style>
table{
cellpadding:0px;
cellspacing:0px;
}
p{
padding:0px;
margin:0px;
}
div{
background-color:#669900;
width:50px;
}
#div1{
height:200px;
}
</style>
<script type="text/javascript" src="../../../js/jquery-1.7.2.min.js"></script>
</head>
<body>
<table border="0" >
<tr align="center" valign="bottom">
<td>
<p><?php echo $d[0]?></p>
<div id="div1"></div>
</td>
<td >
<p><?php echo $d3[0]?></p>
<div style="height:<?php $str=floor(($d3[0]/$d[0])*200); echo $str.'px'?>"></div>
</td>
<td >
<p><?php echo $d4[0]?></p>
<div style="height:<?php $str=floor(($d4[0]/$d[0])*200); echo $str.'px'?>"></div>
</td>
<td >
<p><?php echo $d2[0]?></p>
<div style="height:<?php $str=floor(($d2[0]/$d[0])*200); echo $str.'px'?>"></div>
</td>
</tr>
<tr align="center" valign="top">
<td><p>總計</p></td>
<td><p>一審?fù)ㄟ^</p></td>
<td><p>二審?fù)ㄟ^</p></td>
<td><p>審核通過</p></td>
</tr>
</table>
</body>
</html>
3.效果圖如下所示:

希望本文所述對大家的php程序設(shè)計有所幫助。
您可能感興趣的文章:
- php打造智能化的柱狀圖程序,用于報表等
- PHP實現(xiàn)動態(tài)柱狀圖改進(jìn)版
- JpGraph php柱狀圖使用介紹
- php報表之jpgraph柱狀圖實例代碼
- PHP 柱狀圖實現(xiàn)代碼
- php GD繪制24小時柱狀圖
- PHP中使用GD庫繪制折線圖 折線統(tǒng)計圖的繪制方法
- PHP制作3D扇形統(tǒng)計圖以及對圖片進(jìn)行縮放操作實例
- PHP實現(xiàn)繪制3D扇形統(tǒng)計圖及圖片縮放實例
- php+highchats生成動態(tài)統(tǒng)計圖
- 在PHP上顯示JFreechart畫的統(tǒng)計圖方法
- PHP實現(xiàn)的曲線統(tǒng)計圖表示例
相關(guān)文章
How do I change MySQL timezone?
The MySQL timezone is set to MST (-7 hours GMT/UTC) and is not configurable by you. MySQL is only capable of having 1 timezone setting per mysql daemon. Therefore, you cannot select NOW() and expect a result in a timezone other than MST.2008-03-03
PHP+MySQL使用mysql_num_rows實現(xiàn)模糊查詢圖書信息功能
這篇文章主要介紹了PHP+MySQL使用mysql_num_rows實現(xiàn)模糊查詢圖書信息功能,涉及php使用mysql的like查詢語句進(jìn)行模糊查詢以及mysql_num_rows進(jìn)行結(jié)構(gòu)統(tǒng)計的相關(guān)操作技巧,需要的朋友可以參考下2018-05-05
PHP文字轉(zhuǎn)圖片功能原理與實現(xiàn)方法分析
這篇文章主要介紹了PHP文字轉(zhuǎn)圖片功能原理與實現(xiàn)方法,結(jié)合具體實例形式分析了php基于gd2擴展庫生成圖片的相關(guān)配置及使用方法,需要的朋友可以參考下2017-08-08
PHP讀取ACCESS數(shù)據(jù)到MYSQL的代碼
PHP讀取ACCESS數(shù)據(jù)到MYSQL數(shù)據(jù)庫的代碼,需要的朋友可以參考下。2011-05-05
PHP利用hash沖突漏洞進(jìn)行DDoS攻擊的方法分析
這篇文章主要介紹了PHP利用hash沖突漏洞進(jìn)行DDoS攻擊的方法,實例分析了php利用hash進(jìn)行DDoS攻擊的原理與實現(xiàn)技巧,需要的朋友可以參考下2015-03-03
PHP靜態(tài)方法和靜態(tài)屬性及常量屬性的區(qū)別與介紹
今天小編就為大家分享一篇關(guān)于PHP靜態(tài)方法和靜態(tài)屬性及常量屬性的區(qū)別與介紹,小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧2019-03-03

