Jump to content

Unread and Read states for forum topic


austar

Recommended Posts

Hi, a friend of mine is creating a forum and asked me if I had any ideas on how to go about making topics appear read and unread... all of my suggestions were flawed, so I was wondering if anyone knows the best way to do this?
Link to comment
Share on other sites

You could simply have a column in the users table which holds the ID of the forum topic so when a user visits the topic it updates the user read column to have all that they have visited as well as the one they just clicked on seperated by a space and then to display read and unread you can explode the column by space and then check it against each topic when showing the main page...

Another way of doing this is by adding each user ID to a column in the topics table and then when listing all the topics you explode all user ID's in the topic table column called visitedby or what ever you want and check to see if the user exists in there, if so then the user has read so display the read message/image instead of unread.

second idea is better because less chance of filling the column.

If that didnt make any sence then just tell me and will do a litle code to show you :)
Link to comment
Share on other sites

That was what I originally suggested, though what happens when a topic has a new reply posted to it? and what about if the forum were heavily viewed - the database would rack up to a very considerable size... which could be a problem. Thanks for all your help.

-austen
Link to comment
Share on other sites

[!--quoteo(post=354997:date=Mar 14 2006, 06:52 PM:name=austar)--][div class=\'quotetop\']QUOTE(austar @ Mar 14 2006, 06:52 PM) [snapback]354997[/snapback][/div][div class=\'quotemain\'][!--quotec--]
That was what I originally suggested, though what happens when a topic has a new reply posted to it? and what about if the forum were heavily viewed - the database would rack up to a very considerable size... which could be a problem. Thanks for all your help.

-austen
[/quote]

You can del entrys to the database set by date so old posts are deleted or not wanted.

[code]
Use this code to auto delete all 'read' messages on the first day of the month.  

$deleteday = '01'; // day of month
$today = date("M d, Y");
$deletedate = date("M $deleteday, Y");
if ($deletedate == $today)
{$sql = "DELETE FROM message WHERE isread = '1'"; mysql_query($sql) or die(mysql_error());}

[/code]
Link to comment
Share on other sites

i think he means that it will need to now show as read but if the user id is in the topic `read` field then it will still go up.. the simple solution is on reply page make it update the `read` field to just the reply users address.. therefore will show as new again..
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.