Search code examples
phpmysqlforumconcept

showing threads or posts unread by a user


I am in the process of writing my own basic forum to plug into a code igntier site. I'm a little stuck on how to display threads/latest posts unread by a user.

I was thinking of a table that holds each thread_id visited, but this table has the potential to get rather large.

What's are some ways to approach this requirement?


Solution

  • A simple idea: record the last datetime that a user visits the site/forum/subforum. This could be as granular as the thread or subforum, as you like. Perhaps create/update this key-value pair of thread_id and last_visit_date in a cookie. Perhaps store this in a cookie, rather than in your RDBMS. Ask: is this mission critical data, or an important feature that can/cannot withstand a loss of data?

    When the user returns, find all the threads/posts whose create_date is greater than the last_visit_date for the forum.

    I'm assuming that the act of visiting the forum (list of threads) is same as 'viewing'. Assuming that if the info was presented, that you'd 'viewed' the thread title, regardless of whether you actually drilled into the thread.