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

yipeiwu_com6年前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中数组和字符串的字符函数搞晕,下面总结一下: strlen($string)函数:计算字符...

php导出生成word的方法

本文实例讲述了php导出生成word的方法。分享给大家供大家参考,具体如下: PHP导出word (1)首先,预览html页面,示例化对象,定义要导出的数据 (2)点击下载页面,给id传...

PHP实现的购物车类实例

本文实例讲述了PHP实现的购物车类。分享给大家供大家参考。具体分析如下: 该购物车类是基于CodeIgniter的购物车类仿写实现的。 购物车基本功能如下: 1) 将物品加入购物车 2...

PHPExcel在linux环境下导出报500错误的解决方法

原先我导出为 XLSX 格式,用的是 $objWriter = IOFactory::createWriter($objPHPExcel, 'Excel2007'); 报错,纠...

php5 pdo新改动加载注意事项

前面的#号去了,但是加载不了,仔细一看,哦,原来还有个 extension=php_pdo.dll 于是,就OK了 顺便说下,不要再把ext下的dll文件拷到windows目录下了,在环...