Home >Backend Development >PHP Tutorial >PHP daily, weekly, monthly click ranking statistics_PHP tutorial

PHP daily, weekly, monthly click ranking statistics_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:22:09864browse

Copy code The code is as follows:

$now=time(); //Current time
$StrUpdate = "Update $tbl_article set hits=hits+1";
if(date("d",$lasthittime)==date("d",$now)){//Same day
$StrUpdate = $StrUpdate.", dayhits = dayhits+1";
}else{
$StrUpdate = $StrUpdate.",dayhits = 0";
}
if(date("W",$lasthittime)==date ("W",$now)){//Same week
$StrUpdate = $StrUpdate.",weekhits = weekhits+1";
}else{
$StrUpdate = $StrUpdate.",weekhits = 0";
}
if(date("m",$lasthittime)==date("m",$now)){//Same month
$StrUpdate = $StrUpdate.", monthhits = monthhits+1";
}else{
$StrUpdate = $StrUpdate.",monthhits = 0";
}
$StrUpdate = $StrUpdate.",lasthittime='$now' where id='$id'"; //Update click time
$fsql->query($StrUpdate);

I don’t know if it is easy to use, I will analyze it first
But it feels like there is something wrong. If it is the day, you should first judge that the year and month are the same, and then judge the day.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/324750.htmlTechArticleCopy code The code is as follows: $now=time(); //Current time $StrUpdate = "Update $tbl_article set hits=hits+1"; if(date("d",$lasthittime)==date("d",$now)){//Same day $StrUpdate = $StrU...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn