sortable with php question
most sortable sample online tech you get the list id and update the position, for example
- foreach ($_GET['listItem'] as $position => $item) {
- $sql = "UPDATE table SET position = $position WHERE id = $item";
- }
but actually, we usually use another filed to save the position, maybe like
id label position
2 A 7
6 B 11
9 C 14
if I exchange the first and second data and save, it should be like
id label position
6 B 7
2 A 11
9 C 14
but if we use the sample to do that, it always make the position like
id label position
6 B 0
2 A 1
9 C 2
it's totally wrong, how to make it right?