如何使一个PHP的文章计数器?

编程入门 行业动态 更新时间:2024-10-10 19:17:44
本文介绍了如何使一个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次)
  • 已在内容搜索列表中搜索了该文章(标题和简短的内容描述每页5项,将计入1次.然后,如果打开以阅读整篇文章的内容,则将再计入1次.)
  • 该文章已在首页上通过随机显示(带有标题和简短描述,将计入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的文章计数器?

    本文发布于:2023-10-18 15:35:54,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1504649.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:计数器   文章   PHP

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!