溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶(hù)服務(wù)條款》

使用PHP怎么實(shí)現(xiàn)一個(gè)動(dòng)態(tài)柱狀圖功能

發(fā)布時(shí)間:2021-01-28 11:24:06 來(lái)源:億速云 閱讀:174 作者:Leah 欄目:開(kāi)發(fā)技術(shù)

這期內(nèi)容當(dāng)中小編將會(huì)給大家?guī)?lái)有關(guān)使用PHP怎么實(shí)現(xiàn)一個(gè)動(dòng)態(tài)柱狀圖功能,文章內(nèi)容豐富且以專(zhuān)業(yè)的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。

實(shí)現(xiàn)代碼:

<!DOCTYPE html> 
<?php   
//計(jì)算上一個(gè)月的今天 
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); 
 
//查詢(xún)最近一個(gè)月的總的數(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'";//這條語(yǔ)句也可以 
$d = db()->query($sql)->fetch(PDO::FETCH_NUM); 
//echo "總的數(shù)據(jù)條數(shù):".$d[0]; 
 
//查詢(xún)審核通過(guò)的數(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 "審核通過(guò)的數(shù)據(jù)條數(shù):".$d2[0]; 
 
//查詢(xún)一次審核通過(guò)的條數(shù) 
$sql3=$sql.' and is_pa_check_first=1'; 
$d3 = db()->query($sql3)->fetch(PDO::FETCH_NUM); 
 
//查詢(xún)二次審核通過(guò)的條數(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 ></div> 
        </td> 
        <td > 
          <p><?php echo $d4[0]?></p> 
          <div ></div> 
        </td> 
        <td > 
          <p><?php echo $d2[0]?></p> 
          <div ></div> 
        </td> 
      </tr> 
      <tr align="center" valign="top"> 
        <td><p>總計(jì)</p></td> 
        <td><p>一審?fù)ㄟ^(guò)</p></td> 
        <td><p>二審?fù)ㄟ^(guò)</p></td> 
        <td><p>審核通過(guò)</p></td> 
      </tr> 
    </table> 
  </body> 
</html>

上述就是小編為大家分享的使用PHP怎么實(shí)現(xiàn)一個(gè)動(dòng)態(tài)柱狀圖功能了,如果剛好有類(lèi)似的疑惑,不妨參照上述分析進(jìn)行理解。如果想知道更多相關(guān)知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道。

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

php
AI