论坛如何显示未读主题? [英] How do forums show you unread topics?

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

问题描述

我有一个用php/mysql编写的用户讨论论坛,我想知道大名鼎鼎的论坛如何使其显示哪些主题中有新帖子,通常是通过更改该主题旁边的图标图像而不使用几乎没有任何资源?

I have user discussion forums I coded in php/mysql, I am wanting to know how the big name forums can make it show you which topics have new posts in them, usually by changing an icon image next to the thread without using hardly any resources?

推荐答案

最简单的方法是跟踪某人上次登录的时间.当他们再次访问时,所有已更新的内容从那以后显然是新的".

The simplest way is to track the last time someone was logged in. When they come back to visit, everything which has been updated since then is obviously "new".

但是,这有一些问题,因为注销有效地将所有项目标记为已读.

This has some problems though, since logging out effectively marks all items as read.

我想做的唯一另一种方法是维护一个表,其中包含所有线程以及每个用户已经看到的该线程中的最新帖子.

The only other way I could think to do it would be to maintain a table containing all the threads and the latest post in that thread which each user has seen.

user_id   thread_id   post_id
      1           5        15
      1           6        19

有了这些信息,如果线程#5中有一个帖子的ID大于15,则您知道那里有未读的帖子.仅使用该页面上的最新帖子 的post_id更新此表.这意味着如果有3个页面的新帖子,并且用户仅查看第一页,那么它仍然会知道还有未读的帖子.

With that information, if there is a post in thread #5 which has an ID larger than 15, then you know there's unread posts there. Update this table only with the post_id of the latest post on that page. This means if there's 3 pages of new posts, and the user only views the first, it'll still know there's unread posts.

这篇关于论坛如何显示未读主题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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