Jump to content

Forum Logic Problem


Goose87

Recommended Posts

Hi all,

 

I am writing a custom forum as I need it to fit inside my website.  Anyway, to cut a long story short, I can't seem to crack the logic behind a system within every other forum:

 

How do I show the new posts that have been updated since the last visit EFFICIENTLY??

 

I can think of lots of really inefficient ways to do it, but I can't seem to crack the logic behind it.  If anyone could point me in the right direction, as plain answers never help anyone learn, i would greatly appreciate it.

 

Kind Regards,

 

Goose.

Link to comment
Share on other sites

Hi Goose87,

 

Posts in a forum are saved in rows that have a column of a date time stamp. When you log into a forum the time you last logged in is saved in your user table and that date/time is saved to your session. When you go to the list of posts in a forum, the date time stamp in your session (which was the last time you logged in) is compared with the post date time stamp. That should do it.

Link to comment
Share on other sites

Thanks for the reply hobeau.

 

I understand what you've written, but i came to that conclusion beforen and hit a snag:

 

How do I know which posts they've seen and which ones they haven't? 

 

i.e. you log in at X

 

A post is made at Y

 

You see that post, Y > X, therefore display it's new.

 

But, what about the following:

 

you log in at X.

 

Post Y is made.  Post Z is made shortly after.

 

You view post Y.  Do i update the timestamp for the user then?  If I don't, then the post will keep showing as NEW.  If I DO update it, then Z won't show up as new.  That's what's really got me :(

Link to comment
Share on other sites

maybe try adding and extra session or cookie variable that stores the id's of the post that have been read already ? eg.

 

 

you log in at X

post is made at Y

you view Y, the script creates a new Y variable....saying it has been read....

 

short there after post Z is made....and looks new, because there no new  Z variable.....

 

inefficient ? :-(

 

 

 

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.