Omzy Posted October 1, 2010 Share Posted October 1, 2010 I have a HTML dropdown list which is populated from a MySQL table. I use an auto-incremend ID field. I have also got a sort_order field. I would like to be able to specify the exact order that entries should appear in the dropdown list. Specifically I need some functionality that does the following two things: 1) If I change the sort order of a record to for example "4" then the existing record with sort_order 4 becomes 5, sort_order 5 becomes 6 and so on. 2) If I change the sort order of a record to for example "4" and there is currently no record with sort_order 4, then no other records will be updated. Quote Link to comment https://forums.phpfreaks.com/topic/214947-reorder-mysql-rows/ Share on other sites More sharing options...
trq Posted October 2, 2010 Share Posted October 2, 2010 And you are stuck where exactly? Quote Link to comment https://forums.phpfreaks.com/topic/214947-reorder-mysql-rows/#findComment-1118223 Share on other sites More sharing options...
sasa Posted October 2, 2010 Share Posted October 2, 2010 UPDATE table SET sort_order = sorto_urder + 1 WHERE sort_order >=4 ORDER BY sort_order DESC and after insert row Quote Link to comment https://forums.phpfreaks.com/topic/214947-reorder-mysql-rows/#findComment-1118235 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.