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.
http://www.bkjia.com/PHPjc/324750.htmlwww.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...