网站地图    收藏   

主页 > 后端 > php进阶知识 >

原理就是先判断当前文章的日期是否为当月当日

来源:自学PHP网    时间:2014-09-18 13:09 作者: 阅读:

[导读] 原理就是先判断当前文章的日期是否为当月当日当周的,是就点击数加1...

复制代码 代码如下:

$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程序学习,平面设计学习,以及操作系统学习

京ICP备14009008号-1@版权所有www.zixuephp.com

网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com

添加评论