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使用sql数据库 获取字段问题介绍

在PB开发过程中,由于数据库中使用了 ntext字段,出现以下提示错误,郁闷了很长时间找不到解决方案,后查阅大量资料,终于明白:PB报错: 不能用 DB-Library(如 ISQL)或...

PHP网站安装程序制作的原理、步骤、注意事项和示例代码

1.制作PHP安装程序的原理 其实PHP程序的安装原理无非就是将数据库结构和内容导入到相应的数据库中,从这个过程中重新配置连接数据库的参数和文件,为了保证不被别人恶意使用安装文件,当安装...

PHP使用xpath解析XML的方法详解

本文实例讲述了PHP使用xpath解析XML的方法。分享给大家供大家参考,具体如下: XML文件在PHP网站开发的轻量级应用中使用非常广泛,而PHP解析和读取XML文件的方式有很多种,比...

PHP 数组学习排序全接触第1/2页

array_values($arr) array 返回数组所有元素 复制代码 代码如下: <?php $arr = array("a", "b", "c"); $arr = arr...

PHP整合七牛实现上传文件

七牛支持抓取远程图片 API,用 access_key + secret_key + url 生成 access_token, 把 access_token 加在 header 里,然后...