I have an HTML list that can be sorted (using jQuery's sortable API). I am storing the list items inside a database; each row stores the item's order, and text. How can I store the order of the list items so I do not need to update multiple rows when an item's order changes? List items can be added and removed.
Here's an example of what I'm talking about:
<ol>
<li>Go shopping</li> <!-- Order: 1 -->
<li>Go jogging</li> <!-- Order: 2 -->
<li>Eat</li> <!-- Order: 3 -->
</ol>
The user moves the "Eat" list item to the top, now I must update every single row in the database to store the order.
<ol>
<li>Eat</li> <!-- Order: 3, now update to 1 -->
<li>Go shopping</li> <!-- Order: 1, now update to 2 -->
<li>Go jogging</li> <!-- Order: 2 now update to 3 -->
</ol>