fanfavorite Posted September 29, 2007 Share Posted September 29, 2007 I am trying to allow the users to rearrange the database to display certain items in the order they wish. I want to use something like this: http://www.mattkruse.com/javascript/selectbox/ (the one to move items up and down). I can read all of the information into this select option, which using this example will allow to move items up and down, however I am not sure how to submit the order to the mysql database. Can anyone shed some light on this for me? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/71159-rearranging-database/ Share on other sites More sharing options...
rarebit Posted September 29, 2007 Share Posted September 29, 2007 This seems kinda moot, but... If you were to swap two rows you would read both, then update both. The same applies if you were to alter the full table, e.g. read it all into an array, sort it, then update all the rows. However the database is designed to sort and such like to enable to not have too. If you want to order things and have the ability to change the order, i'd add an extra column called 'weight' and use that. Then when selecting data i'd order by weight. Quote Link to comment https://forums.phpfreaks.com/topic/71159-rearranging-database/#findComment-357900 Share on other sites More sharing options...
fanfavorite Posted September 30, 2007 Author Share Posted September 30, 2007 Ok... I know that a database is designed for sorting, however when you need special sorting for certain situations, the user wants control of setting a custom order. I know that this has to be done using an extra column, however, I need to know how to use http://www.mattkruse.com/javascript/selectbox/ and submit the order. If I hit submit on something like this, it only submits the selected value, not all of the values. Quote Link to comment https://forums.phpfreaks.com/topic/71159-rearranging-database/#findComment-358256 Share on other sites More sharing options...
Ninjakreborn Posted September 30, 2007 Share Posted September 30, 2007 It's pretty much ORDER BY whatever ASC // for ascending order ORDER BY whatever DSC // for descending I just typed that from memory and it's late so double check the syntax. Quote Link to comment https://forums.phpfreaks.com/topic/71159-rearranging-database/#findComment-358259 Share on other sites More sharing options...
fanfavorite Posted September 30, 2007 Author Share Posted September 30, 2007 Thanks for trying to help guys, but I guess I am not explaining myself clearly. I know how to sort the database. What I want to do is be able to determine the order myself through a form such as this http://www.mattkruse.com/javascript/selectbox/. So I want to move records up and down and once I hit submit, the database will be updated to put those items in the order I selected. I can read all the records into the option list and move them up and down, I just need to know from there, how I would go about getting that order into the database? Quote Link to comment https://forums.phpfreaks.com/topic/71159-rearranging-database/#findComment-358266 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.