Home php教程 php手册 summary.php 写得太复杂了。。。。

summary.php 写得太复杂了。。。。

Jun 06, 2016 pm 07:49 PM
complex

很久很久以前写的(2011年的时候)统计数据表中按照每个月份来统计,不过后来数据表的数据太庞大,要采用缓存。 原先的都是直接实时动态查询。现在不能用了,丢掉了。有点可惜~ ~ ~ 其实有蛮多问题。 ?phpdefine('NOROBOT', TRUE);define('CURSCRIPT', 'info

很久很久以前写的(2011年的时候)统计数据表中按照每个月份来统计,不过后来数据表的数据太庞大,要采用缓存。

原先的都是直接实时动态查询。现在不能用了,丢掉了。有点可惜~  ~  ~ 其实有蛮多问题。

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

<?php define('NOROBOT', TRUE);

define('CURSCRIPT', 'infoSummary');

 

require_once '../common.inc.php';

 

$weekArr = array(

"周日",

"周一",

"周二",

"周三",

"周四",

"周五",

"周六",

);

 

 

$yearmonth = trim( $yearmonth );

if(!preg_match("/^((19|20)\d{2}-\d{1,2})$/",$yearmonth)) $yearmonth = date("Y-m");

$whereMonth = $wheresql = " WHERE 1 ";

$wheresql.= " AND DATE_FORMAT( FROM_UNIXTIME(date1),'%Y-%m')='$yearmonth' ";

 

$sqlArr = array();

/* 选出全部月份 */

$sqlArr['Month'] = "SELECT date1,COUNT(tid) AS num,DATE_FORMAT( FROM_UNIXTIME(date1),'%Y-%m') AS `yearmonth`,

 MONTH(FROM_UNIXTIME(date1)) AS `month`, YEAR(FROM_UNIXTIME(date1)) AS `year`

 FROM gk_info_info  $whereMonth  GROUP BY `yearmonth` ORDER BY `year` ASC,`month` ASC  ";

#$queryMonth= DB::query( $sqlArr['Month'] );

$queryMonth= $dsql->Execute('m', $sqlArr['Month'] );

$yearmonthArr = array();

$yearArr = array();

while($rs = $dsql->GetArray('m') ){

  $yearmonthArr[$rs['month']] = $rs;

  $yearArr[$rs['year']]++;

  }

 

 

/* 选出当月的 */

$sqlArr['List'] = "SELECT date1 FROM gk_info_info $wheresql ORDER BY date1 ASC ";

$queryList = $dsql->Execute('L', $sqlArr['List'] );

$REC = array();

while($rs = $dsql->GetArray('L'))

{

  $date = date("Y-m-d",$rs['date1']);

  $REC[$date]['total']++;

}

 

 

 

$nowPHP = date('Y-m-d H:i:s');

$nowMySQL = $dsql->GetOne("SELECT NOW();");

 

//$navtitle = '<a href="phpWorkList.php">工作汇总</a> ? <a href="../phpWorkUserdaily.php">帖子统计</a>';

#include_once admtpl("infoSummary");

include 'tpl/infoSummary.htm';

Copy after login



模板文件 infoSummary.htm

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

<?php mHeader();?>

<div class="divbox">

  <table class="tbBorder" border="1">

    <tr>

      <th width="20%"><div align="center">年份</div></th>

      <th width="14%"><div align="center">月额</div></th>

      <th>总数</th>

    </tr>

    <?php foreach ($yearmonthArr as &$rs) { ?>

    <tr>

      <?php if($lastyear != $rs['year']){ $lastyear=$rs['year']; ?>

      <th class="row2" rowspan="<?php echo $yearArr[$rs[year]]?>"><div align="center">=$rs[year]?>年</div></th>

      <?php } ?>

      <td class="row3"><div align="center"><a href="?yearmonth=<?=%24rs%5Byearmonth%5D?>">=$rs[month]?>月</a></div></td>

      <td><?php echo $rs[num]; if($rs[yearmonth]==$yearmonth) echo "▲▲▲"; ?></td>

    </tr>

    <?php } ?>

  </table>

  <p> </p>

  <input type="button" name="gx" value="开始更新统计" onclick="if(confirm('您是否真的要更新?')) window.location='infoAutoLog.php';">

  <input type="button" name="gx" value="更新所有统计" onclick="if(confirm('您是否真的要更新?')) window.location='infoAutoLog.php?ac=all';">

  <p style="color:#444;font-size:13px;line-height: 22px;">P H P时间:<?php echo $nowPHP?></p>

  <p style="color:#444;font-size:13px;line-height: 22px;">MySQL时间:<?php echo current($nowMySQL);?></p>

  <p> </p>

  <table class="tbBorder" border="1">

    <tr>

      <th width="40"><div align="center">序号</div></th>

      <th width="150"><div align="center">日期</div></th>

      <th>总量</th>

      </tr>

      <?php $xu=0;

      foreach ($REC as $date => $rs)

      {

        $weekDate=date('w',strtotime( $date ));

        $weekYear=date('W',strtotime($date));

        if($lastweekYear != $weekYear) {

          echo '<tr><td colspan="16"> </td></tr>';

          $lastweekYear=$weekYear;

        }

        $xu++;

        ?>

      <tr>

        <td width="5%"><div align="center">=$xu?></div></td>

        <td width="25%" class="row2"><div align="center">

<?php echo $weekArr[$weekDate];?>(<?php echo $date;?>)</div></td>

        <td width="70%"><a href="infoList.php?date1=<?php%20echo%20%24date;?>" target="_blank"><?php echo $rs['total'];?></a></td>

      </tr>

      <?php } ?>

  </table>

  <script language="javascript" type="text/javascript" src="http://quote.51.la/?id=4525618&mb=5"></script>

  <p> </p>

  <div class="code"><?php ShowSQL();?></div>

  </div>

<?php mFooter();?>

Copy after login





Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)