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
https://forums.phpfreaks.com/topic/237407-php-mysql-order-by/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.