Jump to content

Rearranging Database


fanfavorite

Recommended Posts

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!

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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. 

Link to comment
Share on other sites

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? 

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.