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