PHP 日,周,月点击排行统计

yipeiwu_com5年前PHP代码库
复制代码 代码如下:

$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实现执行外部程序的方法详解

本文实例讲述了PHP实现执行外部程序的方法。分享给大家供大家参考,具体如下: 在一些特殊情况下,会使用PHP调用外部程序执行,比如:调用shell命令、shell脚本、可执行程序等等,今...

PHP提取中文首字母

复制代码 代码如下:<?     function pykey( $py_key)   &...

php简单复制文件的方法

本文实例讲述了php简单复制文件的方法。分享给大家供大家参考,具体如下: <?php /** *author:果冻 *qq:52091199 *wyg517.blog....

php通过递归方式复制目录和子目录的方法

本文实例讲述了php通过递归方式复制目录和子目录的方法。分享给大家供大家参考。具体实现方法如下: <?php function recurse_copy($src,$...

PHP5.2中date()函数显示时间与北京时间相差8小时的解决办法

问题: php函数date("Y-n-d   H-i-s");   输出的时间与当地时间相差8个小时. 解决思路 北京时间是东8区,可能是时区问...