zoukankan      html  css  js  c++  java
  • Discuz论坛发帖统计

    工作需要 老板一句话 要统计发帖数目 小竹子我 开始搬砖

    历史久远了 仿佛是 discuz6.0版本

    输出 execl 格式【execl 2003】

    需要 pdo 扩展

     1 <?php
     2 $date=31;//论坛7月1-'.$date.'号发帖统计
     3 header('Cache-Control: no-cache, must-revalidate');
     4 header('Content-type: application/vnd.ms-excel');
     5 header('Content-Disposition: filename=论坛7月1-'.$date.'号发帖统计(包括回复的帖子数目).xls');
     6 ?>
     7 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     8 <html xmlns="http://www.w3.org/1999/xhtml">
     9 <head>
    10 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    11 <title>包括回复的帖子数目</title>
    12 </head>
    13 <body>
    14 <?php 
    15 $users = array(
    16                 "员工1"=>"'sbest'",
    17          "员工2"=>"'水水','丨写往事'",
    18          "员工3"=>"'jackal2112'",
    19          "员工4"=>"'jordan0823'"
    20         );
    21 ?>
    22 <table width="100%" border="1" cellspacing="1" cellpadding="1">
    23   <tr align="center">
    24     <td nowrap><b>日期</b></td>
    25     <?php
    26     foreach($users as $user=>$u_sql){
    27       echo "<td nowrap><b>".$user."</b></td>";
    28     }    
    29     ?>
    30   </tr>
    31   <?php
    32     $j=1;
    33     for($i=1;$i<=$date;$i++){
    34       echo "<tr align="center"><td nowrap>2011-7-".$j++."</td>";
    35       foreach($users as $user=>$u_sql){
    36         $pdo = new PDO("mysql:host=localhost;dbname=forum_xxx_com;port=3306","root","mima",array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
    37         $start = "2011-7-".$i;
    38         if($i==$date){
    39           $end = "2011-8-1";
    40         }else{
    41           $end = "2011-7-".($i+1);
    42         }
    43         $start = strtotime($start);
    44         $end = strtotime($end);
    45         $fuck = $pdo->query("SELECT tid FROM forum_posts where author in ({$u_sql}) and dateline BETWEEN {$start} and {$end}");
    46         $rowCount = 0;
    47         $rowCount = $fuck->rowCount();
    48         echo "<td nowrap>".$rowCount."</td>";
    49       }
    50       echo "</tr>";
    51     }    
    52     ?>
    53 </table>
    54 </body>
    55 </html>

     

  • 相关阅读:
    使用java.util.Timer来周期性的执行制定的任务
    Android中为APP创建快捷方式的原理(自己的理解)
    View.setTag()的作用
    用3种方法在 operator= 中处理“自我赋值”
    关于 const 成员函数
    复制构造函数 与 赋值操作函数
    Command 模式
    Mediator 模式
    求一棵普通树的两个结点的最低公共祖先
    Memento 模式
  • 原文地址:https://www.cnblogs.com/zhusanjie/p/3659868.html
Copyright © 2011-2022 走看看