RSX_ Posted May 25, 2011 Share Posted May 25, 2011 I'm currently trying to grab data from my database for my chatbox, which when displayed, displays in an ascending order, when I call it to descend, it shows the messages ONCE in descending order, then just repeats but in random order.. $sql = "SELECT * FROM `message` WHERE `chat_id` = 1 AND `message_id` > $last ORDER BY `message_id` DESC"; Database: message_id | name 1 RSX 2 RSX 3 RSX 4 RSX RSX: 4 RSX: 3 RSX: 2 RSX: 1 RSX: 4 RSX: 3 RSX: 2 RSX: 4 RSX: 3 RSX: 4 It is ordering it correctly, just repeats, I'm using Ajax, could that be the problem, or is it within the PHP code? Edit: I read it wrong, it displays as shown under "output". Quote Link to comment Share on other sites More sharing options...
Dathremar Posted May 25, 2011 Share Posted May 25, 2011 It looks fine to me, if these are multiple requests. It is defined by the "`message_id` > $last" thingy, so it outputs => 4 -3 -2 -1 then 4 - 3 - 2 => 4 - 3 => 4 ... Are You changing the $last in every request? Quote Link to comment Share on other sites More sharing options...
RSX_ Posted May 25, 2011 Author Share Posted May 25, 2011 Basically, $last = (isset($_GET['last']) && $_GET['last'] != '') ? $_GET['last'] : 0; , after requesting should I unset $last? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.