PHP 日,周,月点击排行统计
PHP 日,周,月点击排行统计
发布时间:2016-12-29 来源:查字典编辑
摘要:复制代码代码如下:$now=time();//当前时间$StrUpdate="Update$tbl_articlesethits=hits+...

复制代码 代码如下:

$now=time(); //当前时间

$StrUpdate = "Update $tbl_article set hits=hits+1";

if(date("d",$lasthittime)==date("d",$now)){//同一天

$StrUpdate = $StrUpdate.",dayhits = dayhits+1";

}else{

$StrUpdate = $StrUpdate.",dayhits = 0";

}

if(date("W",$lasthittime)==date("W",$now)){//同一周

$StrUpdate = $StrUpdate.",weekhits = weekhits+1";

}else{

$StrUpdate = $StrUpdate.",weekhits = 0";

}

if(date("m",$lasthittime)==date("m",$now)){//同一月

$StrUpdate = $StrUpdate.",monthhits = monthhits+1";

}else{

$StrUpdate = $StrUpdate.",monthhits = 0";

}

$StrUpdate = $StrUpdate.",lasthittime='$now' where id='$id'"; //更新点击时间

$fsql->query($StrUpdate);

不知道好不好用啊,先分析一下再说了

不过感觉好像有些问题,如果是天的应该先判断年月都是一样的,然后再判断天。

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新php教程学习
热门php教程学习
编程开发子分类