Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do forums show you unread topics?

Tags:

php

mysql

forums

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?

like image 926
JasonDavis Avatar asked Jan 04 '10 03:01

JasonDavis


1 Answers

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

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.

like image 91
nickf Avatar answered Oct 20 '22 15:10

nickf