SN1P3R_85 Posted September 2, 2008 Share Posted September 2, 2008 hi everybody, i have a mysql table that is sorted by Id, that auto increments. I want to put the rows into an array, and then print elements from each row, but if i did this the normal way, it would print elements from Id 1, then Id 2, then Id 3, etc. I want it to do the opposite, so start with the highest, and print it all until it reaches the lowest Id. how would i do this? thanks Link to comment https://forums.phpfreaks.com/topic/122328-solved-mysql-fetch-array-opposite/ Share on other sites More sharing options...
Third_Degree Posted September 2, 2008 Share Posted September 2, 2008 ORDER BY `id` DESC Link to comment https://forums.phpfreaks.com/topic/122328-solved-mysql-fetch-array-opposite/#findComment-631656 Share on other sites More sharing options...
trq Posted September 2, 2008 Share Posted September 2, 2008 You would do this with your query. eg; SELECT data FROM tbl ORDER BY id DESC Link to comment https://forums.phpfreaks.com/topic/122328-solved-mysql-fetch-array-opposite/#findComment-631657 Share on other sites More sharing options...
SN1P3R_85 Posted September 2, 2008 Author Share Posted September 2, 2008 so the DESC makes it add new data to the top? Link to comment https://forums.phpfreaks.com/topic/122328-solved-mysql-fetch-array-opposite/#findComment-631658 Share on other sites More sharing options...
Third_Degree Posted September 2, 2008 Share Posted September 2, 2008 no it simply returns the records in order of highest id to lowest id. Link to comment https://forums.phpfreaks.com/topic/122328-solved-mysql-fetch-array-opposite/#findComment-631659 Share on other sites More sharing options...
SN1P3R_85 Posted September 2, 2008 Author Share Posted September 2, 2008 oh, thanks alot, i'll try it right now Link to comment https://forums.phpfreaks.com/topic/122328-solved-mysql-fetch-array-opposite/#findComment-631660 Share on other sites More sharing options...
SN1P3R_85 Posted September 2, 2008 Author Share Posted September 2, 2008 yep, it works, thanks alot. I was bothering with the php when i could have done this the whole time hehe Link to comment https://forums.phpfreaks.com/topic/122328-solved-mysql-fetch-array-opposite/#findComment-631665 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.