Jump to content

[SOLVED] DB Records Retrieved Out Of Order


refiking

Recommended Posts

I am trying to retrieve the records in order by the did field.  For some reason it retrieves the first one and then skips to the record with a did of 10.  Here is my code:

 

$sql = mysql_query("SELECT * FROM dregs WHERE lid = '$lid' AND sid = '$sid' AND tm = '' ORDER BY did LIMIT 3");

Link to comment
Share on other sites

It sounds like the numbers may be saved in your database as text - if that is the case, then when you order it, it will order like this♦:

 

1

10

11

12

13

14

15

16

17

18

19

2

20

21

22

...etc

 

They will only order as 1,2,3,4,5 etc if they are saved as numbers.

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.