Jump to content

Archived

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

austar

Unread and Read states for forum topic

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?

Share this post


Link to post
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 :)

Share this post


Link to post
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

Share this post


Link to post
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]

Share this post


Link to post
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..

Share this post


Link to post
Share on other sites

×

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.