How to do this: I want to update my Inbox script of my custom made site which is about social networking. When new message come through It should update message list and total number of message instantly (Like Gmail and yahoo do). I am using PHP. Currently: When a member is logged in the inbox, it does not notify new incoming messages until the next log in again. What i want: Inbox message should flash when new message come through Can anyone guide me how to achieve this.
Can you provide me any reference to this with sample script. Off-course I am also searching in google
OK this is something very basic that shows the idea behind the such a system Assume you have a div where it shows the inbox like this <div id="inbox">Inbox</div> HTML: Then you would include the jquery file in the header and have a javascript like this <script type="text/javascript"> function checkMessages() { $('#inbox').load('ajax/messages.php'); setTimeout("checkMessages();",10000); } $(window).load(function () { setTimeout("checkMessages();",10000); } </script> HTML: Then all you need is the file ajax/messages.php which would have something like this <?php mysql_connect(host,user,pass); mysql_select_db(dbname); $sql = 'SELECT COUNT(*) as `tot` FROM `messages` WHERE `user`='.$_SESSION['userid'].' AND `status`=0'; $query = mysql_query($sql); $result = mysql_fetch_assoc($query); if ($result['tot']==0) { echo 'Inbox'; } else { echo '<b>Inbox ('.$result['tot'].')</b>';} ?> PHP: This above example simply changes the "Inbox" to "Inbox (2)" and makes it bold. It checks that every 10 seconds. This should give you a good idea how to do it.
Alternatively you can do if a statement to check if theirs any unread messages (assuming you have a column for this), and if their is you could add <blink> tags.