Copy codeThe 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 as January
$ StrUpdate = $ StrUpdate. ", monthhits = monthhits + 1 ";
} Else {
$ StrUpdate = $ StrUpdate. ", monthhits = 0 ";
}
$ StrUpdate = $ StrUpdate. ", lasthittime = '$ now' where id = '$ id'"; // update the click Time
$ Fsql-> query ($ StrUpdate );
I don't know how easy it is. Let's analyze it first.
However, it seems that there are some problems. If it is a day, you should first judge that the year and month are the same, and then judge the day.