如何制作一个php文章计数器?
我写了一些简单的文章脚本。现在我想添加一些文章计数器。
如果有3种可能性就应该做一个文章计数器。
- 该文章已被打开阅读。(每页仅一篇整篇文章,计1次)
- 该文章已在内容搜索列表中被搜索到(标题和简短内容描述每页5条,计1次)。那么如果打开阅读整篇文章内容,则会再算1次。)
- 该文章已通过随机方式显示在首页中(带有标题和简短描述,将算1次)
有什么好的建议如何做到这些更好的?
哪种数据库设计更好?将文章和计数放在一张表中?或者制作两张桌子?
谁能给我推荐一些php文章计数器脚本
,如果主要规则写入像class.php
这样的文件,然后包含到我的每个页面中。
谢谢。
I write some simple article scripts. Now I want add some article counter.
If there have 3 possibility it should make an article counter.
- the article has been opened for read.(only one whole article per page, it will count 1 time)
- the article has been searched in a content search list(with title and short content description 5 items per page, it will count 1 time. then if open to read whole article content, it will count another 1 time.)
- the article has been showed in the home page by Random (with title and short description, it will count 1 time)
Is there any good suggestion how to do these better?
Which database design is better? put article and count number in one table? or make two tables?
Can anyone recommend me some php article counter script
, if the main rules write into a file like class.php
then include into my every page.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您要计算一篇文章的点击次数,请创建一个列,并在每次有人访问该页面时向其中添加一个列。
类似于:
将表
table
中的列count
加 1。然后您就可以检索该值。If you are counting the number of hits on an article, create a column and add one to it every time somebody accesses the page.
Something like:
Would increment the column
count
in the tabletable
by 1. Then you could just retrieve that value.您可以做的是使用自动递增的数据库,并在查看页面时仅递增该值,并根据需要显示该值。
以下是如何设置自动增量 。
然后更新“值”(你不必实际更新它会AI的任何内容)
然后只显示视图
这超出了我的想象 - 它应该可以工作。
What you could do is use the database that auto increments and just increment that value when the page is viewed, and display that value if you want.
Here is how you can setup the auto increment.
Then update the "value" (you don't have to actually update anything it will AI)
Then just display the view
This is off the top of my head - it should work.