Imagine we’re having a message box system for our website users, what I want to do is that if a new message is sent to a member, while the targeted member is on his inbox, he could see a notification message right after he gets the new message.
For having this, we could have the “new_messages” div which is gonna refresh using jQuery with setInterval() and sends the query to see if there is a new message or not, but if we have 10.000 members, we can not send 10.000 queries, this could just kill the server!!! I want a notification to be shown for the targeted member only when hi gets a new message. something like that we could have a “listen” div in our page, it gets fired when the new message is triggered.
I’ve also read about the MySQL trigger, but it seems that’s not gonna be a solution to this since that just could fire another SQL statement to the DB and not helping showing a notification to the user.
So what’s the solution for such scenario?
Thanks in advance
You could look at PHP Comet system question for ideas on pushing live events from the server to the browser. Or try looking into the details of using Websockets as well. But these don’t really go down well with PHP.
But if you looking to implement some kind of a chat try looking at http://www.phpfreechat.net/