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 $foo = 'Bob'; // 将 'Bob' 赋给 $foo $bar = &$foo; // 通过 $bar 引用 $foo echo $f...

php中设置index.php文件为只读的方法

为index.php文件设置只读属性后,木马就没权限给你文件末尾追加广告了。下面我们看具体的代码,设置index.php只读: 复制代码 代码如下:<?phpfunction se...

php简单截取字符串代码示例

本文实例讲述了php简单截取字符串的方法。分享给大家供大家参考,具体如下: //截取摘要 public static function mbsubstr($str){ $strl...

理解PHP中的stdClass类

相信大家跟我一样,会经常看到和下面很类似的PHP代码: 复制代码 代码如下:$user = new stdClass();$user->name = 'gouki'; 这样的代码,...

php创建、获取cookie及基础要点分析

php创建、获取cookie及基础要点分析

本文实例讲分析了php创建、获取cookie及基础要点。分享给大家供大家参考。具体如下: 假设为:cookie1.php文件 复制代码 代码如下:<?php setCook...