如何使一个PHP的文章计数器? [英] how to make a php article counter?

查看:64
本文介绍了如何使一个PHP的文章计数器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一些简单的文章脚本.现在,我要添加一些文章计数器.

I write some simple article scripts. Now I want add some article counter.

如果有3种可能性,则应将其设为商品计数器.

If there have 3 possibility it should make an article counter.

  1. 该文章已被打开以供阅读.(每页仅一篇整篇文章,将计入1次)
  2. 已在内容搜索列表中搜索了该文章(标题和简短的内容描述每页5项,将计入1次.然后,如果打开以阅读整篇文章的内容,则将再计入1次.)
  3. 该文章已在首页上通过随机显示(带有标题和简短描述,将计入1次)

有什么好的建议,如何做得更好?

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?

如果主要规则写入class.php这样的文件,然后将其包含在我的每一页中,谁能向我推荐一些php article counter script.

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.

谢谢.

推荐答案

您可以做的是使用自动递增的数据库,并在查看页面时递增该值,并根据需要显示该值.

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.

您可以在此处设置自动增量.

然后更新值"(您不必实际更新任何内容)

Then update the "value" (you don't have to actually update anything it will AI)

mysql_query("UPDATE COUNTER SET HITS = ''");

然后只显示视图

$result = mysql_query("SELECT * FROM PAGEVIEWS");

while($row = mysql_fetch_array($result))
  {
  echo $row['COUNTER'];
  }

这是我的头上的-它应该可以工作.

This is off the top of my head - it should work.

这篇关于如何使一个PHP的文章计数器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆