开发者

Count hits for post using php and mysql

开发者 https://www.devze.com 2023-01-16 04:20 出处:网络
How i can develop a hit counter for my posts. I have a mysql table with following cols idtitlebodyhits how i can increment hits by 1 whenever a user read post entry.

How i can develop a hit counter for my posts.

I have a mysql table with following cols

id title body hits

how i can increment hits by 1 whenever a user read post entry.

Please h开发者_StackOverflow社区elp.


In the page where you show your post you should update database.

I.e. you show post post.php?id=53 so in post.php you have to do

'UPDATE table SET hits = hits + 1 WHERE id = ' . (int) $_GET['id']
0

精彩评论

暂无评论...
验证码 换一张
取 消