Hy!
Here is my problem: i have a profile and this profile has for example 100 images.
When someone visit this profile the first image will be the first result of my query that sorts by updated_at.
But if the user would want to put the image with the (id = 8) to be the first, then (id = 22) then (id = 88) and so on?
I need to put another field or is really necessary a new table to make a custom sort on images? and maybe someone explain this to me how to do?
thanks, i appreciate your help 😉
EDIT:
(i appreciate if could be made with a really small amount of rows affected)
for example if i have 100 images, and i swap the 4th with the 89th will be affected only 2 rows
if i have to delete the 1st image, 99 images should be updated? thats really a bad situation. Or the field could begin with number 2?(the first image had the order_field = 1)
EDIT2:
if i have 100 images, with the order_field from 1 to 100, and then the user want to add a new image and to be first, then all them should be changed, right? this is something i dont want…
Create other column/field in the same table called
positionororder.In this case you’ll store the image position in this column. When you retrieve the images for the user profile, you’ll know beforehand in which position to show the user’s images.
This of course requires that the user specify the image relevance (position). This column in the DB table can even be null. If it’s null you can show this image in whatever position. The images that have this field filled should appear in the specified order.
Just and idea…