PHP关于日/周/月点击统计代码
PHP #统计2012-04-22 21:23
代码编写的原理就是,先判断当前文章的日期是否为当月当日当周的,是就点击数加1。
$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); 相关文章
- CentOS安装PHP cannot find -lltdl 错误的解决办法 2012/04/20
- PHP中文验证码函数 2012/04/19
- PHP简单实用的分页函数 2012/04/19
- PHP 文件上传脚本 2012/04/19
- PHP验证邮件地址函数 2012/04/19
- PHP防SQL注入漏洞过滤函数 2012/04/19
- php open_basedir用法 安全设置 2012/04/19
- PHP开发安全规则 2012/04/18
- PHP的可变变量名 2012/04/18
- php的闭合标签要不要写 2012/04/15