用js和php改变数据库中的数据顺序

I am not sure if the title is 100% accurate, but here's my problem.

I have a website where n user can upload images, I want to enable the user to order the images he has uploaded and save them in that order and later preview them in the exact order.

The ordering can be done same time as the upload or later on. I am using plupload. My idea is to save the source of every image in the database with an additional column that would represent order number and use ORDER BY when getting the images.

But for every new image I have to check the number of images I already have and that many SQL request will be too slow. And with the adding of new images and rearranging them come a lot of UPDATE statements that also slows the database. And this means that I will also have to check the old place and new of every image and change it if I have to, which meant more SQL statements.

All of this didn't seem like a good approach so I was wondering if I could get some pointers on a different approach or optimization. But I would like to keep plupload if possible.

Normally an ORDER BY $order is sufficient using values like 0,1,2,3 with default 0 and where lowest is first.

If you really not want to make any changes to your own DB you can consider writing a code so that it uses the local storage on the client's side. But this would result in that when the users makes access from another computer, that data will not be available.

So whatever option is going to be given, still the best is to use your own db for it. When your code is written well, there should not be any problem at all to run these queries.