Jump to content

Forum


iarnazca

Recommended Posts

I'm designing a forum and I want to know how people get the "new posts" to display.  usually i'm pretty good at figuring out how to do it but this one is escaping me.  It cant be a mysql value on the forum entry's row in the table because that would change for every one as soon as one person viewed it.  But I cant imagine that its an entry in the users row because there are SO many posts.

 

maybe a date and time on the user and a date and time updated in the forum entries table?  off to code....

Link to comment
Share on other sites

It depends on how you want to handle "new posts."

 

Do you want it to be unread until somebody reads it?

 

You could associate a last_updated value with each thread, and maintain a "relationship table" for last_read, connecting a user id with a thread id and a date.

 

Something like

id, user_id, thread_id, timestamp

 

 

And every time a user opens a thread, create/update their corresponding relationship with that thread. To see if it's unread or read, have a database function to determine if a thread's last_updated timestamp is newer or older than the last_read value for that user + that thread.

 

It's just like friend relationships on social networking, connecting an object with a target, or an event log.

Link to comment
Share on other sites

It will be easier if you maintain the data of users&posts details in a separate table.

 

Scenario:

------------

create a table read_posts(what ever the name you want put the table name) with id,user_id,post_id.

when you are displaying the list of new posts from posts table depends upon the created date.just check with this table depends upon the post_id and the user_id(the id of user who logged in) if the record exists in that table that means the user "read" that post if not he didn't read so you can highlight with different color.

 

Link to comment
Share on other sites

Essentially the same thing I said but instead of naming the table "last_read" you are naming it "read_posts" and once it is read, it can never be seen as "unread" again because you have no date.

 

Another thing to do would be associate a value in your "users" table called "read_before." This would enable users to "mark all posts as unread" without creating 50,000 new rows. Just set the current date in "read_before." Any posts taking place before that date are considered "read."

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.