elrobbo6 Posted May 18, 2011 Share Posted May 18, 2011 OK, so I have a question about databases and how they sort things being loaded into them. I have a database that I have images uploaded to (some people dont like to do it this way but this is what is going to work for my project). I have it set up with an id column that auto-increments. When I upload the files for some reason it is putting the highest id number first and the second one is the lowest then it goes in order from there. Why would this be happening and how do I correct it? Quote Link to comment https://forums.phpfreaks.com/topic/236719-noob-question-about-databases/ Share on other sites More sharing options...
Psycho Posted May 18, 2011 Share Posted May 18, 2011 How do you know it is putting one record before another? The only way to "see" the records in a database (that I know of) is to run a query and then display the results. The query will determine the sort order. If you don't provide one then I believe the implied sort order is the order in which the records are created. But, I would NEVER rely upon that. If you want your records in a particular order then order them using the query. Quote Link to comment https://forums.phpfreaks.com/topic/236719-noob-question-about-databases/#findComment-1216854 Share on other sites More sharing options...
jonsjava Posted May 18, 2011 Share Posted May 18, 2011 It should key off the primary key, and go by ORDER ASC on that. You do have a Primary key, right (you set id to Primary)? Quote Link to comment https://forums.phpfreaks.com/topic/236719-noob-question-about-databases/#findComment-1216855 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.