如何显示与主题相对应的总回复数? [英] How to display total number of replies correspond to a topic?

查看:104
本文介绍了如何显示与主题相对应的总回复数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在threads.php中创建了以下html表







发布者:At :开:主题名称:回复:



myname12308:51:51 AM11th 2013主题-2 0

myname00108:51:10 AM11th 2013年9月主题-1 0



问题是假设我在主题-2中有一个回复。现在,如果我尝试显示对应于topic-2的回复总数,则只需

显示就像这样 -





发布者:在:开:主题名称:回复:



pankaj645 08:51:51 AM 2013年9月11日topic-2 1

pankaj645 08:51:10 AM 2013年9月11日主题-1 1



正如您所看到的那样,显示总数也对应于主题-1。

plz告诉我该怎么办?

I have created a following html table in threads.php



Posted by:At: On: Topic Name: Replies:

myname12308:51:51 AM11th September 2013 topic-2 0
myname00108:51:10 AM11th September 2013 topic-1 0

Problem is suppose i have one reply in topic-2. Now if i try to display the total number of replies correspond to topic-2, it is just
display it like this-


Posted by:At: On: Topic Name: Replies:

pankaj645 08:51:51 AM 11th September 2013topic-2 1
pankaj645 08:51:10 AM 11th September 2013topic-1 1

As you can see it displaying total number correspond to topic-1 too.
plz tell me what should i do?

推荐答案

由于HTTP是无状态协议,因此每个PHP脚本都是在一个单独的上执行的HTTP请求。要计算它们,您需要有一些持久对象来累积某个主题的请求数(在某些约束下,无论它是什么)。此类对象可以是服务器端的文件或数据库。在每个请求中,您打开一个文件,读取值,递增它并将文件写回。或修改数据库中的值。



-SA
As HTTP is a stateless protocol, each of your PHP scripts is executed on a separate HTTP request. To count them, you need to have some persistent object to accumulate the number of requests on a certain topic (under certain constraints, whatever it is). Such object could be a file on your server side or a database. On each request, you open a file, read the value, increment it and write the file back. Or modify a value in your database.

—SA


这篇关于如何显示与主题相对应的总回复数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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