iarnazca Posted February 13, 2010 Share Posted February 13, 2010 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.... Quote Link to comment Share on other sites More sharing options...
iarnazca Posted February 13, 2010 Author Share Posted February 13, 2010 no that wont work because all the posts would be 'viewed' when I changed the users date to the forum date. back to square 1. Quote Link to comment Share on other sites More sharing options...
iarnazca Posted February 14, 2010 Author Share Posted February 14, 2010 no body knows huh? lol time to look at phpbb's code I guess. Quote Link to comment Share on other sites More sharing options...
xjake88x Posted February 16, 2010 Share Posted February 16, 2010 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. Quote Link to comment Share on other sites More sharing options...
prashanth Posted February 16, 2010 Share Posted February 16, 2010 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. Quote Link to comment Share on other sites More sharing options...
xjake88x Posted February 16, 2010 Share Posted February 16, 2010 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." Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.