PHP 日,周,月点击排行统计
作者:bea
代码如下: $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(dat
代码如下:
$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中创建空文件的代码[file_put_contents vs touch]
- PHP取进制余数函数代码
- 用phpmailer实现简单openvpn用户认证的实现代码
- PHP采集腾讯微博的实现代码
- Php图像处理类代码分享
- php中可能用来加密字符串的函数[base64_encode、urlencode、sha1]
- php 阴历-农历-转换类代码
- yii框架中的Url生产问题小结
- fgetcvs在linux的问题
- PHP异步调用socket实现代码
- 114啦源码(114la)不能生成地方房产和地方报刊问题4级页面0字节的解决方法
- PHP警告Cannot use a scalar value as an array的解决方法
- Trying to clone an uncloneable object of class Imagic的解决方法
- win2003服务器使用WPS的COM组件的一些问题解决方法
- php通过COM类调用组件的实现代码
- 关于IIS php调用com组件的权限问题
- Uncaught exception com_exception with message Failed to create COM object
- 比file_get_contents稳定的curl_get_contents分享
- 学习使用curl采集curl使用方法