austar Posted March 14, 2006 Share Posted March 14, 2006 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? Quote Link to comment https://forums.phpfreaks.com/topic/4928-unread-and-read-states-for-forum-topic/ Share on other sites More sharing options...
shocker-z Posted March 14, 2006 Share Posted March 14, 2006 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 :) Quote Link to comment https://forums.phpfreaks.com/topic/4928-unread-and-read-states-for-forum-topic/#findComment-17372 Share on other sites More sharing options...
austar Posted March 14, 2006 Author Share Posted March 14, 2006 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 Link to comment https://forums.phpfreaks.com/topic/4928-unread-and-read-states-for-forum-topic/#findComment-17471 Share on other sites More sharing options...
redarrow Posted March 14, 2006 Share Posted March 14, 2006 [!--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] Quote Link to comment https://forums.phpfreaks.com/topic/4928-unread-and-read-states-for-forum-topic/#findComment-17477 Share on other sites More sharing options...
shocker-z Posted March 15, 2006 Share Posted March 15, 2006 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.. Quote Link to comment https://forums.phpfreaks.com/topic/4928-unread-and-read-states-for-forum-topic/#findComment-17754 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.