Jump to content

PHP / MySQL order by


RSX_

Recommended Posts

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".

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.