userH
userH

Reputation: 187

Display realtime user status using AJAX and PHP from a MySQL database

I have a simple mysql query which shows users last status. I now want to go further and create a page to show users most recent status without refreshing. The mysql DB is dynamically updated with the users status.

So all that is required is for the page rendering the mysql to refresh with the latest user status without me having to hit the refresh button.

Could anyone provide guidance on how I go about doing this. Thanks

Upvotes: 1

Views: 1157

Answers (1)

pregmatch
pregmatch

Reputation: 2657

You need push into page, not pool. It is kind of stupid to do poling from database. Here is how that works.

  1. Let asume that you have n users on you page.
  2. Every time that status is changed (you insert that into you DB)

    2.1 As this happens you need to push signal to your webpage (use Strophe library).

    2.2 In order to push something to page you need Strophe instance running.

    2.3 If your website is PHP, here is good class for communicating with Strophe instance.

    I can do this for your but you will be more happy if you do this on your own. That real time stuff are very interesting.

Upvotes: 1

Related Questions