Jump to content

"New posts/no new posts" system in forum


Kitu

Recommended Posts

Hi,
I have a small forum on my website, what I started to recode reacently. It is a fairly simple script and I would like to add few functions to it, one of which would be the new posts system. Problem is, that I have absolutly no idea how to do it...all I know is, that it has something to do with cookies? I would appritiate any help...I don't even know what to google to find any appropriate tutorials.
Link to comment
https://forums.phpfreaks.com/topic/32273-new-postsno-new-posts-system-in-forum/
Share on other sites

Its not done by cookies, I know that, because I delete my cookies daily, and it still shows New Posts

I will do this, a bit complex, but a nice result
First have a table, with
TrackerID INT(11) auto_increment,
UserID INT(11),
PostID INT(11),
LastViewed DateTime,
Primary Key (TrackerID)

Then
Everytime a User views a post
First
Check the table, to see if that user has seen it
Something like
SELECT * FROM Tracker WHERE UserID = '".$UserID."' AND PostID = '".$PostID."'";

If there is a result, Update that row, to have LastViewed to be NOW
Else, INSERT into the table.

So know you know when the user last viewed the post.

Then when displaying all of the topics
get the Last Updated Time (Last post)
then run a query against the tracker to see if the LastUpdate is Before or After the User last viewed the Post
If its before, he has seen it
If its after, its NEW

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.