depojones Posted May 31, 2010 Share Posted May 31, 2010 Thank you for reading my post. I have a public chat room that is working at the moment. How do i hide old conversation from newly logged in users. Like if a user just log-in, I don't want him/her to see what has been said before. Thanks once again Quote Link to comment https://forums.phpfreaks.com/topic/203455-phpmysql-output-query/ Share on other sites More sharing options...
premiso Posted May 31, 2010 Share Posted May 31, 2010 Just setup your "chat" fetching script for when a user logs in to not pull anychats before that time. Quote Link to comment https://forums.phpfreaks.com/topic/203455-phpmysql-output-query/#findComment-1065857 Share on other sites More sharing options...
depojones Posted May 31, 2010 Author Share Posted May 31, 2010 do you mind giving me a pseudo code kind of example. just a hint on what to do. i believe I will be able to write the code in php. thanks Quote Link to comment https://forums.phpfreaks.com/topic/203455-phpmysql-output-query/#findComment-1065858 Share on other sites More sharing options...
depojones Posted May 31, 2010 Author Share Posted May 31, 2010 what kind of query to do I need to make on my database. I still haven't figured your logic out. Just setup your "chat" fetching script for when a user logs in to not pull anychats before that time. Please elaborate Quote Link to comment https://forums.phpfreaks.com/topic/203455-phpmysql-output-query/#findComment-1065870 Share on other sites More sharing options...
jcbones Posted May 31, 2010 Share Posted May 31, 2010 I suppose you are logging a unix timestamp for each chat entry. You would then need to define a timestamp when a user logs in, and not display any chat messages that occurred before that timestamp. //user logs in if(isset($_SESSION['timestamp'])) { $time = $_SESSION['timestamp']; } else { $time = $_SESSION['timestamp'] = time(); } $sql = "SELECT * FROM `chat` WHERE `room` = '$room_id' AND `time` > '$time'"; Or, something along those lines. Quote Link to comment https://forums.phpfreaks.com/topic/203455-phpmysql-output-query/#findComment-1065872 Share on other sites More sharing options...
depojones Posted May 31, 2010 Author Share Posted May 31, 2010 Hi all, I was able to compare the last time a new message was posted against the time a user login. My question now is, If the last time a new message was posted is less than the time the user log in, how will my sql query look like so that it doesn't display the old message If($newmsgtime < userlogintime){ $sql=mysql_query(????) thanks for your time Quote Link to comment https://forums.phpfreaks.com/topic/203455-phpmysql-output-query/#findComment-1065899 Share on other sites More sharing options...
depojones Posted June 1, 2010 Author Share Posted June 1, 2010 can someone help me am still finding it hard to solve this problem... Quote Link to comment https://forums.phpfreaks.com/topic/203455-phpmysql-output-query/#findComment-1066312 Share on other sites More sharing options...
jcbones Posted June 1, 2010 Share Posted June 1, 2010 $sql = "SELECT * FROM `chat` WHERE `room` = '$room_id' AND `time` > '$time'"; Since I see no code on this thread, I cannot give you a clear answer. 1. We don't know what format $newmsgtime is. 2. We don't know what format userlogintime CONSTANT is. 3. We don't know what the time column in your database is. 4. We don't know what the name of your time database column is. Quote Link to comment https://forums.phpfreaks.com/topic/203455-phpmysql-output-query/#findComment-1066349 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.