This will mainly be done using jQuery. This is just a question of a periodic server request:
setInterval(function(){ $.post("getUpdates.php", function(response){ showInfoBar(response); }); }, 10000);
This will request updates every 10 seconds. You can do this as soon as the page loads. Regarding the PHP code in getUpdates.php:
if (!isset($_SESSION["userid"])) die("You are not logged in"); $updates = getUpdatesForUser($_SESSION["userid"]); if ($updates) { print json_encode($updates); } else { print "No updates"; }
As for get-updates, you can do this as a table in your database:
userid | time | updatemsg
-------------------------------------------------- -----------
28 | 2009-08-21 12:53:02 | You've received the 'uber' badge. Getting updates for users is as simple as querying this table for all new updates. You can create a field that indicates when the update was sent and should not be resubmitted.
All this is very confused, but should give you a very general idea of how to implement it.
source share