技术宅,fat-man

增加语言的了解程度可以避免写出愚蠢的代码

导航

< 2025年3月 >
23 24 25 26 27 28 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 1 2 3 4 5

统计

只是备份的PHP代码

复制代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtm
l1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<script type="text/javascript" src="/js/jjquery.js"></script>
<link type="text/css" href="/js/datepicker/ui.all.css" rel="stylesheet" />
<script type="text/javascript" src="/js/datepicker/ui.core.js"></script>
<script type="text/javascript" src="/js/datepicker/ui.datepicker.js"></script>
<script type="text/javascript"
        src="/js/datepicker/ui.datepicker-zh-CN.js"></script>
<link type="text/css" href="/js/datepicker/demos.css" rel="stylesheet" />

<script type="text/javascript"
        src="/js/tablesorter/jquery.tablesorter.js"></script>
<style type="text/css">
@import "/js/tablesorter/assets/css/default.css";
</style>

<style type="text/css">
body {
        background-color: #DCDCDC;
        font-size: 12px;
        font-family: "EIIa";
}

p {
        line-height: 150%;
        margin: 0;
        font-size: 14px;
}

a:link {
        color: orange;
}

a:active {
        color: orange;
}

a:visited {
        color: orange;
        text-decoration: none;
}

a:hover {
        color: orange;
}

/*table.tr.td{font-size:12px;}*/
td {
        font-size: 13px;
        font-weight: bold;
}

#nav {
        float: right;
        width: 100%;
}

#nav ul li {
        list-style: none;
        float: left;
        padding: 5px 0px;
        margin: 0 30px;
}

#nav ul li a {
        font-size: 15px;
}

#page a:link {
        color: black;
}

#page a:active {
        color: blue;
}

#page a:visited {
        color: orange;
        text-decoration: none;
}

#page {
        float: both;
        width: 100%;
        position: absolute;
        left: 50px;
}

#page ul li {
        list-style: none;
        float: left;
        padding: 5px 5px;
        margin: 0px 5px;
        border: 1px solid;
}

#page ul li a {
        font-size: 13px;
}
</style>

<script>
$(function() {
        $(".date-pick").datepicker();
});

$(function() {
    $(".asort").tablesorter({widgets:["zebra"]});   
    $(".bsort").tablesorter({widgets:["zebra"]});   
});
</script>


<script language="javascript"><!--
function SetColor(o,a,b,c,d)
{
    var t=document.getElementById(o).getElementsByTagName("tr");
    for(var i=0;i<t.length;i++)
    {
        t[i].style.backgroundColor=(t[i].sectionRowIndex%2==0)?a:b;
        t[i].onclick=function(){
        if(this.x!="1")
        {
            this.x="1";
            this.style.backgroundColor=d;
        }
        else{
            this.x="0";
            this.style.backgroundColor=(this.sectionRowIndex%2==0)?a:b;
        }
    }
        t[i].onmouseover=function()
        {
            if(this.x!="1")this.style.backgroundColor=c;
        }
        t[i].onmouseout=function()
        {
            if(this.x!="1")this.style.backgroundColor=(this.sectionRowIndex%2==0)?a:b;
        }
    }
}
--></script>

</head>
<?php

$project_name = "book";

require_once("../mod_db_link.php");

$today=date("Y-m-d",strtotime("-1 days"));

$search_date=isset($_REQUEST["datelist"])?$_REQUEST["datelist"]:$today;



/***********************************/


$stat_year = date("Y");
$stat_month = date("m");
$my_month = $_GET["my_month"];

if($my_month == null)
{
        if ($y==null){
                $y=$stat_year;
        }

        if ($m==null){
                $m=$stat_month;
        }

        $my_month="{$y}-{$m}";
}

//echo $my_month;
///**********************************/





$statdb = statdb();

$bookdb = book_contentdb();

echo "<p>统计项目:充值统计</p>";

echo "<p>统计时间:$search_date </p>";
echo "<br>";

global $statdb,$search_date,$bookdb;
$sql = "select cpid,cpname from bc_book_charge_cp order by cpid asc;";
$results = mysql_query($sql,$bookdb);

$thlist = array();
//array_push($thlist,array("cpid"=>"stat_date","cpname"=>"统计日期"));
while($row=mysql_fetch_array($results))
{
        //$thlist[$row["cpid"]] = $row["cpname"];
        array_push($thlist, array("cpid"=>$row["cpid"], "cpname"=>$row["cpname"]));
}
array_push($thlist, array("cpid"=>"all", "cpname"=>"整体数据"));

$listinfo = array();
//$sql="select * from stat_cp_charge where stat_date like '2013-10%' order by stat_date desc , cpid asc ;";

$sql="select * from stat_cp_charge where stat_date like '".$my_month."%' order by stat_date desc , cpid asc ;";
$results = mysql_query($sql,$statdb);
while($row=mysql_fetch_array($results))
{
        $cpid      = $row["cpid"];
        $stat_date = $row["stat_date"];
        $conv_rate = $row["conv_rate"];
        $arpu      = $row["arpu"];

        if (! array_key_exists($stat_date,$listinfo))
        {
                $listinfo[$stat_date] = array();
                $listinfo[$stat_date]["stat_date"] = $stat_date; 
        }

        $arpu = sprintf("%.2f",$arpu);
        $conv_rate = sprintf("%.4f",$conv_rate);
        $conv_rate = $conv_rate * 100;
        $conv_rate = $conv_rate."%";
        $listinfo[$stat_date][$cpid] = $conv_rate." | ".$arpu;
}

draw_table($thlist,$listinfo);

function draw_table($thlist, $listinfo)
{

        echo "<table class='asort' border=1 cellspacing=0 cellpadding=0 width=60%>";

        echo "<thead><tr>";
        echo "<th align=center><nobr>统计日期</nobr></th>";
        foreach($thlist as $i)
        {
                echo "<th align=center><nobr>".$i["cpname"]."</nobr></th>";
        }
        echo "</tr></thead>";

        foreach($listinfo as $list)
        {
                echo "<tr>";
                echo "<td height=30 align=center><nobr>".$list["stat_date"]."</nobr></td>";
                foreach($thlist as $th)
                {
                        $cpid = $th["cpid"];
                        if(array_key_exists($cpid,$list))
                        {
                                echo "<td height=30 align=center><nobr>".$list[$cpid]." </nobr></td>";
                        }
                        else
                        {
                                echo "<td height=30 align=center><nobr> - </nobr></td>";
                        }
                }
                echo "</tr>";

        }

        echo "<tr>";
        foreach($tstruc as $count=>$tdv)
        {
                if("item"==$tdv){
                        echo "<td height=30  width='50px' align=center>总计</td>";
                }else{
                        echo "<td height=30 align=center><nobr>".$sum[$tdv]."</nobr></td>";
                }

        }
        echo "</tr>";
        echo "</table>";
        echo "<br><br>";
}
?>
复制代码

 

posted on   codestyle  阅读(150)  评论(0编辑  收藏  举报

编辑推荐:
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
阅读排行:
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· .NET周刊【3月第1期 2025-03-02】
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· [AI/GPT/综述] AI Agent的设计模式综述
历史上的今天:
2012-10-25 python:装饰模式的一个实现
点击右上角即可分享
微信分享提示