web_master Posted December 23, 2007 Share Posted December 23, 2007 Hi, I got online users - when somebody go online, his NAME goes to "chat_online" table, and than see it in query. I got in browser cookies: name password session How can I remove (delete) online user from "chat_online" table when he close the browser window? "chat_online" table have: chat_online_id chat_online_user chat_online_session rows. When somebody goes online his username and session goes in the table. <?php //Query return from dbase $query_return = mysql_query("SELECT DISTINCT `chat_online_user` FROM `chat_online` ORDER BY `chat_online_user` ASC"); if(!$query_return) { print mysql_error(); exit; } while($request = mysql_fetch_array($query_return)) { print "<p class=\"TXT_USER_ADMIN\">".$request['chat_online_user']."</p>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/82932-remove-user-from-table-when-browser-window-is-closed/ Share on other sites More sharing options...
papaface Posted December 23, 2007 Share Posted December 23, 2007 You cant do that with PHP on the fly unless you use AJAX or some other technology that links server with client in real time. Quote Link to comment https://forums.phpfreaks.com/topic/82932-remove-user-from-table-when-browser-window-is-closed/#findComment-421789 Share on other sites More sharing options...
web_master Posted December 23, 2007 Author Share Posted December 23, 2007 You cant do that with PHP on the fly unless you use AJAX or some other technology that links server with client in real time. No need remove in real time - can I do this with cookie? (after 1-5 min) Quote Link to comment https://forums.phpfreaks.com/topic/82932-remove-user-from-table-when-browser-window-is-closed/#findComment-421791 Share on other sites More sharing options...
papaface Posted December 23, 2007 Share Posted December 23, 2007 You'd have to have a new table. Everytime the user performs an action update the table. Then have a cron run every 2-3 minutes and check if their has been any activity in the last X minutes from the users. If there hasnt, then delete their name from the chat_online table. Quote Link to comment https://forums.phpfreaks.com/topic/82932-remove-user-from-table-when-browser-window-is-closed/#findComment-421793 Share on other sites More sharing options...
web_master Posted December 23, 2007 Author Share Posted December 23, 2007 You'd have to have a new table. Everytime the user performs an action update the table. Then have a cron run every 2-3 minutes and check if their has been any activity in the last X minutes from the users. If there hasnt, then delete their name from the chat_online table. I see, I think I must to find other way to do that - Ajax or other - because maybe the user will be there few hours without to want to say something. Where can I find something about - ajax - the other way to do that? Quote Link to comment https://forums.phpfreaks.com/topic/82932-remove-user-from-table-when-browser-window-is-closed/#findComment-421795 Share on other sites More sharing options...
papaface Posted December 23, 2007 Share Posted December 23, 2007 http://www.google.co.uk/search?q=updating+a+mysql+table+with+ajax&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a Quote Link to comment https://forums.phpfreaks.com/topic/82932-remove-user-from-table-when-browser-window-is-closed/#findComment-421796 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.