一段根据日期查询并把结果显示出来的代码

一段根据日期查询并把结果显示出来的代码

admin
2017-04-14 / 0 评论 / 123 阅读 / 正在检测是否收录...
温馨提示:
本文最后更新于2018年06月25日,已超过2134天没有更新,若内容或图片失效,请留言反馈。

<?
    include "./sess.php";
    include "./config.php";
    $logined=$_SESSION["logined"];
    if($logined!=1){
        print "<center><font color=red size=8>你没有权限,请先从<a href=/>这里</a>进行登录 。</font></center>";
        exit;
    }
include "./sbl/config.php";
if($_GET[startdate]==''){
echo '起始日期为空,系统自动统计当天的数据';
$_GET[startdate]=date("Ymd");
}
if($_GET[enddate]==''){
echo '终止日期为空,系统自动统计当天的数据';
$_GET[enddate]=date("Ymd"); 
}
if ($_GET[enddate] > date("Ymd")) {
echo '终止日期不能大于当前日期,系统自动统计到当天的数据';
$_GET[enddate]=date("Ymd");
}
if ($_GET[startdate] > $_GET[enddate]) {
echo '日期错误 终止日期必须大于或等于起始日期,系统自动统计当天的数据';
$_GET[startdate]=date("Ymd");
$_GET[enddate]=date("Ymd");
}
$timeb=time()+(3600*24*10);
$dateb=date("Y-m-d",strtotime(date("$_GET[enddate]")." +10 day ")); 

if (!$conn)
  {exit("Connection Failed: " . $conn);}
$sql0="select ....略;
$sql1="select ...略 
and a.enddate+1 between  '$_GET[startdate]' and '$_GET[enddate]'
group by 1, 2, 3, 4, 5
into temp sbold with no log";
$sql2="select b.*
from sbold a, sbnew1 b
where a.comcode=b.comcode
...略 with no log";
$sql3="select a.comcode[1,7],count(*) oldsl,
sum(sumpremium) oldsumpremium
from sbold a
where 1=1
group by 1
into temp old with no log;
select a.comcode[1,7],count(*) newsl,
sum(sumpremium) newsumpremium
from sbnew a
where 1=1
group by 1
into temp new with no log";
$sql4="select ....";
//$rs0=odbc_exec($conn,$sql0);
//$rs1=odbc_exec($conn,$sql1); 
//$rs2=odbc_exec($conn,$sql2);
//$rs3=odbc_exec($conn,$sql3);
$rs=odbc_exec($conn,$sql4);
if (!$rs)
  {exit("Error in SQL");}
if (file_exists("./sbl/test.txt")){
unlink("./sbl/test.txt");
}
while (odbc_fetch_row($rs))
{
    $comcode=odbc_result($rs,"comcode");
    $AppliName=odbc_result($rs,"oldsl");
  $AppliCode=odbc_result($rs,"newsl");
    $operatedate=odbc_result($rs,"sbl");
     $OperatorCode=odbc_result($rs,"oldsumpremium");
  $UnderwriteName=odbc_result($rs,"newsumpremium");
 
  $content= "<tr><td class='style3'>$comcode</td><td class='style3'>$AppliName</td><td class='style3'>$AppliCode</td><td class='style3'>$operatedate</td><td class='style3'>$OperatorCode</td><td class='style3'>$UnderwriteName</td></tr>";
file_put_contents('./sbl/test.txt',$content,FILE_APPEND);
}
$content=file_get_contents("./sbl/test.txt");
$getcontent=ob_get_contents();
echo "</table>";

ob_clean();

ob_start(); 

$title=统计时间: .$_GET[startdate]. 到 .$_GET[enddate];
echo "$title \n"; 
//echo $dateb;
$gettitle=ob_get_contents();
//ob_clean();

odbc_close($conn);
$fp=fopen("./sbl/mb.htm","r"); 
$str=fread($fp,filesize("./sbl/mb.htm"));
$str=str_replace("{content}",$content,$str); 
$str=str_replace("{title}",$title,$str); 
$handle=fopen("./sbl/index.htm","w+"); 
fwrite($handle,$str); 
fclose($handle);
if (file_exists("./sbl/test.txt")){
unlink("./sbl/test.txt");
}

echo "恭喜,数据报表已生成,<a href=./sbl/index.htm>点这里查看</a>";
?>

0

评论 (0)

取消