Home > Backend Development > PHP Tutorial > php+mysql如何实现每天的文章点击数

php+mysql如何实现每天的文章点击数

WBOY
Release: 2016-06-13 13:38:24
Original
1246 people have browsed it

php+mysql怎么实现每天的文章点击数
如题,比如
表 wz

id content hit

1 内容 2

2 内容2 5

3 内容3 8

. . .

n 内容n 5

每次访问表wz里面的内容 hit 对应id 就会自增1 update `wz` set hit=hit+1 

现在我想知道 每天 他们的 hit 增加了 多少 怎么写代码呀

------解决方案--------------------
另建一个表view ,有字段:
postid INT // 所阅读的文章的id,在wz里面
viewtime datetime 或者 INT(10)存为时间戳 // 阅读文章时间
想获取当天某文章的阅读数
$today = date("Y-m-d 00:00:00");
$SQL = "SELECT count(*) AS `viewnum` FROM `view` 
WHRER postid='{$postid}' AND `viewtime` > '{$today}' ";

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template