I have a table with a auto-increment id which orders the rows. I made a form where you can change a row's order.
id item
1 - row a
2 - row b
3 - row c
4 - row d
But the primary key(auto-increment) does not allow doubles like the following:
id item
1 - row a
2 - row b
2 - row c
4 - row d
Is there a way to change the order using a mysql or php sript so i can rearrange the order:
id item
1 - row a
2 - row b
3 - row d
4 - row c
- in the example above row d and c have changed, eg. row c has moved 1 up and d has moved 1 down.
Any help would be appreciated!
UPDATE
The rows are dynamic. if, say, item c is deleted the count would be 1, 2, 4. How would you make that they close the gap if some are deleted