0
I have a table with n fields, one of which is the 'order' (obviously it is sequential: 1, 2, 3, n...):
id | ordem | nome
------------------------
1 | 1 | Fabio
3 | 2 | Gilmar
2 | 3 | Rodrigo
9 | 4 | Marcos
I am developing a drag and drop table to change this order, so how do I always keep this sequence without skipping any number and nor repeat them?
To make it difficult, there will also be manual order, that is, the user accesses the record and selects the desired position. Therefore, all the records below this should be changed.
Note: My system provides 4 parameters after dragging: id, Direction (forward/back), fromPosition and toPosition that could be used in the query.
Just so you know, you’re only using mysql or this one using some programming language for this, like php, python, java, something else. If it is only in the bank you should see about procedures and/or triggers.
– Marcelo Diniz
I’m using php, but initial idea was to do the operation via database. But if there is a solution via php will be welcome.
– fabioAlmeida