I have a few rows in a database and in one of the columns I want to have a value that sets the order when the rows are displayed.
The user should be able to set this value to change the order in which the rows are displayed on the page.
Has anyone seen the way YouTube does this? In the playlists settings there are small input fields next to the videos in the list which contains a number which you can change. If you take the video with number 8 in the list and change its number to 1 it ends up first in the list.
The hard part is to make sure all numbers are properly in order so that there are no duplicates.
Let's say there are 5 rows. The index values are 1, 2, 3, 4, 5 for the rows. If I take row 4 and change its index value 4 to the value 2, then the index values on rows 2 and 3 needs to increase so that there is always 1, 2, 3, 4, 5 and never any duplicates. I didn't use 0 as the first value in this example because it's easier to understand ...
Go to the complete details ...