I am looking for a way to efficiently allow a user to order a list of items displayed to them in a form. Currently each item is stored in the database with an extra field named "rank", this is an integer field. The idea is when I grab the items from the database I order them using this field and then spit out the items into a form, one row after another with links for changing the order of the item either up or down in the list. Ideally the first item and the last item will have the appropriate links. That is you cannot move the first item up, nor can you move the last item down.
When a user clicks on one of these links to move an item either up or down, the script should create new "rank" entries for the items displayed and then update the database, grab the latest list correctly ordered and then redraw the interface to reflect the latest order.
Please see the attached PDF file for an idea of what the interface should look like. I am not necessarily going for a pretty design here, and overall am looking for someone to write the central logic of this application more than anything else, as the functionality will be used for any number of item lists. So I am pretty flexible about the items, generic data will suffice, simplistic form will be fine.
A rudimentary table for purposes of this application would have the following field: