It would be equally easy to swap any two items in the list, not just two
adjecent items. Just swap sort_order values.
Yup... I think that is the key!
Basically as they are inserted I will look up the max sort_order value
for that group so far and increase that by one for the current insert.
The
Michael J. Pawlowsky wrote:
I'm trying to create the most efficient way to allow a user to change
the display order of a group of rows in a table.
Lets say the basic table is:
id
group_id
name
sort_order
The query to display it would be
"SELECT id, name FROM mytable WHERE group_id = $x ORDER BY s
I wouldn't use a loop but an UPDATE statement instead.
If I understand you correctly, all of your records are in the same group
but you need them displayed in a user-defined order. It would be MUCH
easier to manage that if the sort order values were already in sequential
order. You may need to
I'm trying to create the most efficient way to allow a user to change
the display order of a group of rows in a table.
Lets say the basic table is:
id
group_id
name
sort_order
The query to display it would be
"SELECT id, name FROM mytable WHERE group_id = $x ORDER BY sort_order"
Now when I displa