Question

I am working right now on a forum and I'm almost done, but now I came to a point where it kinda got difficult.

You're probably familiar with the phpBB forum. There's this cool feature which flags posts as read and unread.

I found here a similar thread about this, but I didn't really get the solution.

If I save the time when the user logs in and mark all posts which have been created in the past, it might work. But now, what's next? The user read an unread post and I want to mark it as "read" but the other posts should still stay flagged as "unread" until he reads them. I kinda have to store this data, don't I?

And I've actually been also thinking about saving that data in cookies. How about that?

Was it helpful?

Solution

You should have a table with a many-to-many reltaionship:

marked_as_read
--------+--------
user_id | post_id
--------+--------

Remove any posts older than (say) 30 days, to keep the table under hysterical size.

In your PHP code, mark any posts not present in this table AND are younger than 30 days as not read. When an answer is read, place it here.

When a post is edited/updated, remove it from all users in this table.

OTHER TIPS

Plain and simple: store it in a database. One table with a user_id column and a post_id/thread_id column, which you keep updating when somebody reads a post or updates a post/thread. Yes, that's a lot of data, but it's not really so much that it'd make any problems for a database.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top