I'm trying to create an something that detects when a user is online or not. So when a user goes online one of the fields in my mysql database gets updated to online. So how do I show all the other users that he is online without reloading their page, I'm guessing I have to use ajax. But how?
Need Help with ajax
Started by
Tomproggramer
, Mar 27 2011 04:06 PM
1 reply to this topic
#1
Posted 27 March 2011 - 04:06 PM
#2
Posted 01 April 2011 - 10:33 PM
Without giving you the code, the answer is this:
You should to have Ajax (your own code, jQuery, mootools, etc.) call a PHP script every couple of seconds that will look for all users that are online according to your MySQL database. If you're going to do this, be sure that you have a cron job set up for a PHP script that will automatically set people to offline in the MySQL database if they don't have any activity in the past 1, 2, 5, 10, 15, 20, etc. minutes depending on the type of website you're running.
You should to have Ajax (your own code, jQuery, mootools, etc.) call a PHP script every couple of seconds that will look for all users that are online according to your MySQL database. If you're going to do this, be sure that you have a cron job set up for a PHP script that will automatically set people to offline in the MySQL database if they don't have any activity in the past 1, 2, 5, 10, 15, 20, etc. minutes depending on the type of website you're running.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users