11-11-2011, 09:32 AM
Hi . I am building a live chat using mysql and the database is updated because of users entries . So the number ow rows in the table changes constantly . And need to use a query which will select the rows that hasnt been selected.
SO how do I do that ?
Thank you in advance!!!
11-11-2011, 06:45 PM
Put an auto_increment field in the table. Say it is named chatNumber
When you send the current messages out to a user, make sure the chatNumber values are included.
That is, your AJAX URL might be something like moreMessages.php?last=731
So in the PHP code, you just do
$sql = "SELECT * FROM chatMessages WHERE chatNumber > " . $_GET["last"];
What could be simpler?