Pixel2Life Forum: Need Help with ajax - Programming and General Web Design - Pixel2Life Forum

Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Need Help with ajax ajax and php

Array

#1 User is offline   Tomproggramer 

  • Young Padawan
  • Pip
  • Group: Members
  • posts 1
  • Joined: 27-March 11

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?
0

#2 User is offline   JoeyMagz 

  • Young Padawan
  • Pip
  • Group: Members
  • posts 79
  • Joined: 27-June 08
  • 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

Share this topic:


  • You cannot start a new topic
  • You cannot reply to this topic

0 user(s) are reading this topic
members, guests, anonymous users