DrumAt5280
Technical User
I have an Image Table in my DB which holds the names of the images.
When a user deletes an image, let's say the first one dsc001.jpg, I would like this:
To reorder in to this:
I am guessing there is two way to accomplish this, the first way would be to:
Or by some MySQL function like ALTER TABLE command that does this for you that I don't know how to use.
Any ideas on the best way to accomplish this?
Code:
ImageId | imageName | imageOrder
1 | dsc0001.jpg | 1
2 | dsc0002.jpg | 2
3 | dsc0003.jpg | 3
4 | dsc0004.jpg | 4
When a user deletes an image, let's say the first one dsc001.jpg, I would like this:
Code:
ImageId | imageName | imageOrder
2 | dsc0002.jpg | 2
3 | dsc0003.jpg | 3
4 | dsc0004.jpg | 4
To reorder in to this:
Code:
ImageId | imageName | imageOrder
2 | dsc0002.jpg | 1
3 | dsc0003.jpg | 2
4 | dsc0004.jpg | 3
I am guessing there is two way to accomplish this, the first way would be to:
Code:
<Delete the desired row from the DB, in this case #1>
<Query the same table to return the recordset, order by ImageId>
<Loop and UPDATE query to renumber the imageOrder column based on the the recordset from the last query>
Or by some MySQL function like ALTER TABLE command that does this for you that I don't know how to use.
Any ideas on the best way to accomplish this?