喜悦国际村 
» 游客:  注册 | 登录 | 搜索 | 统计 | 帮助

RSS 订阅当前论坛  

喜悦证交所已经关闭

上一主题 下一主题
     
标题: 怎么把mysql的函数改成sql的函数?  
 
tianme (tianme)
版主
Rank: 7Rank: 7Rank: 7
彗星召唤师


UID 15408
精华 4
积分 4895
帖子 5108
金钱 4855 喜悦币
威望 40
人脉 0
阅读权限 100
注册 2002-7-23
来自 火星
状态 离线
[广告]: q m
怎么把mysql的函数改成sql的函数?

那位老大帮我改一下
<?PHP
include "conf.inc";
$dateg=date( "G" );
$datej=date( "j" );
$daten=date( "n" );
$datey=date( "Y" );

$hourc="hc".$dateg;
$hours="hs".$dateg;
$houru="hu".$dateg;
$datec="dc".$datej;
$dates="ds".$datej;
$dateu="du".$datej;
$monthc="mc".$daten;
$months="ms".$daten;
$monthu="mu".$daten;
$yearc="yc".$datey;
$years="ys".$datey;
$yearu="yu".$datey;

$n=$datey-1999;
$db = mysql_connect($dbserver,$dbuser,$dbuser_pw) or die ("Error Connecting to SQL Server");
mysql_select_db ($dbname,$db) or die ("Error connecting database");

$sql="select * from $dbtable where city='$city'";
$result = mysql_query($sql) or die("mySQL-Error: Cannot $sql!");
//判断$dbtable纪录是否存在
if($theresult=mysql_fetch_array($result))
{

if ($seltime!="")
{

if ($seltime=="hour")
{
print "<br>近24小时的统计:";
print "<table><tr><td>时间</td>";
for ($i=0; $i<=23; $i++) {
print "<td>";
print $i;
print "</td>";
}
print "</tr>";
print "<tr><td>计数</td>";
for ($i=0; $i<=23; $i++) {
print "<td>";
print $theresult[hc.$i];
print "</td>";
}
print "</tr><tr><td>访问</td>";
for ($i=0; $i<=23; $i++) {
print "<td>";
print $theresult[hs.$i];
print "</td>";
}
print "</tr><tr><td>人数</td>";
for ($i=0; $i<=23; $i++) {
print "<td>";
print $theresult[hu.$i];
print "</td>";
}
print "</tr>";
exit;
}

if ($seltime=="day")
{
print "<br>近31天的统计:";
print "<table><tr><td>时间</td>";
for ($i=1; $i<=31; $i++) {
print "<td>";
print $i;
print "</td>";
}
print "</tr>";
print "<tr><td>计数</td>";
for ($i=1; $i<=31; $i++) {
print "<td>";
print $theresult[dc.$i];
print "</td>";
}
print "</tr><tr><td>访问</td>";
for ($i=1; $i<=31; $i++) {
print "<td>";
print $theresult[ds.$i];
print "</td>";
}
print "</tr><tr><td>人数</td>";
for ($i=1; $i<=31; $i++) {
print "<td>";
print $theresult[du.$i];
print "</td>";
}
print "</tr>";
exit;
}
if ($seltime=="month")
{
print "<br>近12个月的统计:";
print "<table><tr><td>时间</td>";
for ($i=1; $i<=12; $i++) {
print "<td>";
print $i;
print "</td>";
}
print "</tr>";

print "<tr><td>计数</td>";
for ($i=1; $i<=12; $i++) {
print "<td>";
print $theresult[mc.$i];
print "</td>";
}
print "</tr><tr><td>访问</td>";
for ($i=1; $i<=12; $i++) {
print "<td>";
print $theresult[ms.$i];
print "</td>";
}
print "</tr><tr><td>人数</td>";
for ($i=1; $i<=12; $i++) {
print "<td>";
print $theresult[mu.$i];
print "</td>";
}
print "</tr>";
exit;
}
if ($seltime=="year")
{
print "<br>近".$n."年的统计:";
print "<table><tr><td>时间</td>";
for ($i=1; $i<=$n; $i++) {
print "<td>";
print 1999+$i;
print "</td>";
}
print "</tr>";

print "<tr><td>计数</td>";
for ($i=1; $i<=$n; $i++) {
print "<td>";
print $theresult[yc.(1999+$i)];
print "</td>";
}
print "</tr><tr><td>访问</td>";
for ($i=1; $i<=$n; $i++) {
print "<td>";
print $theresult[ys.(1999+$i)];
print "</td>";
}
print "</tr><tr><td>人数</td>";
for ($i=1; $i<=$n; $i++) {
print "<td>";
print $theresult[yu.(1999+$i)];
print "</td>";
}
print "</tr>";
exit;
}
print "</table>";

}
//$sql="select count,scount,user,$hourc,$hours,$houru,$datec,$dates,$dateu,$monthc,$months,$monthu,$yearc,$years,$yearu from $dbtable where city='$city'";
//$result = mysql_query($sql) or die("mySQL-Error: Cannot $sql!");

print "<br>";
print "总体统计情况:";
print "<table><tr><td>";print "本小时点击数:";
print $theresult[$hourc];
print "</td><td>   ";print "本小时访问数:";
print $theresult[$hours];
print "</td><td>   ";print "本小时新增人数:";
print $theresult[$houru];
print "</td><td>   ";
print "详细统计信息";

print "</td></tr><tr><td>";print "今日点击数:";
print $theresult[$datec];
print "</td><td>   ";print "今日访问数:";
print $theresult[$dates];
print "</td><td>   ";print "今日新增人数:";
print $theresult[$dateu];
print "</td><td>   ";
print "<a href=stat.php?city=".$city."&seltime=hour>近24小时统计</a>";

print "</td></tr><tr><td>";print "本月点击数:";
print $theresult[$monthc];
print "</td><td>   ";print "本月访问数:";
print $theresult[$months];
print "</td><td>   ";print "本月新增人数:";
print $theresult[$monthu];
print "</td><td>   ";
print "<a href=stat.php?city=".$city."&seltime=day>近30天统计</a>";

print "</td></tr><tr><td>";print "今年点击数:";
print $theresult[$yearc];
print "</td><td>   ";print "今年访问数:";
print $theresult[$years];
print "</td><td>   ";print "今年新增人数:";
print $theresult[$yearu];
print "</td><td>   ";
print "<a href=stat.php?city=".$city."&seltime=month>近12月统计</a>";

print "</td></tr><tr><td>";print "总计点击数:";
print $theresult[count];
print "</td><td>   ";print "总计访问数:";
print $theresult[scount];
print "</td><td>   ";print "总计来访人数:";
print $theresult[user];
print "</td><td>   ";
print "<a href=stat.php?city=".$city."&seltime=year>近".$n."年统计</a>";
print "</td></tr></table>";
}
else
{
print "没有这个站点的数据";
}



$sql="select * from $dbtable1 where city='$city' order by id";
$result = mysql_query($sql) or die("mySQL-Error: Cannot $sql!");
print "<br>最近20位来访者信息:";
print "<table><tr><td>来访次数</td><td>访问者ip</td><td>浏览器版本</td><td>操作系统</td><td>访问时间</td><td>来自何方</td></tr>";
    while ($myrow = mysql_fetch_array($result)) {
        $tmph=date ("G" ,$myrow[timestamp]);
        $tmpi=date ("i" ,$myrow[timestamp]);
        $tmps=date ("s" ,$myrow[timestamp]);
print "<tr><td>";
print $myrow["user_count"]+1;
print "</td><td>";
print $myrow["user_ip"];
print "</td><td>";
print $myrow["brower"];
print "</td><td>";
print $myrow["operos"];
print "</td><td>";
print $tmph."时";
print $tmpi."分";
print $tmps."秒";
print "</td><td>";
print $myrow["referer"];
print "</tr>";

//     printf("%s %s %s %s %s %s %s %s %s %s时%s分%s秒 %s</a> \n",$myrow["id"], $myrow["user_id"], $myrow["user_count"]+1,$myrow["user_ip"], $myrow["city"], $myrow["brower"],$myrow["operos"], $myrow["target"], $myrow["document"], $tmph,$tmpi,$tmps, $myrow["referer"]);
    }
//debug data
//print $seltime;
?>
2003-7-28 08:01 PM#1
查看资料  Blog  发短消息  顶部
 
3945
该用户已被删除









[推荐阅读] 正则表达式问题
*** 作者被禁止或删除 内容自动屏蔽 ***
2004-12-27 04:27 AM#2
顶部
     


  可打印版本 | 推荐给朋友 | 订阅主题 | 收藏主题 | 开通个人空间  


 




Powered by Discuz! 6.1.0  © 2001-2010 Comsenz Inc.
Processed in 0.029243 second(s), 6 queries

(冀ICP备05009913号) 管理员:sadly 邮箱/MSN: sadly@phpx.com QQ:824008(长隐) 清除 Cookies - - Archiver - WAP