Jump to content


Photo

Need Help with ajax


  • Please log in to reply
1 reply to this topic

#1 Tomproggramer

Tomproggramer

    Young Padawan

  • Members
  • Pip
  • 1 posts

Posted 27 March 2011 - 04:06 PM

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?

#2 JoeyMagz

JoeyMagz

    Young Padawan

  • Members
  • Pip
  • 79 posts
  • Gender:Male
  • Location:Chesapeake, VA

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users