![]() |
Ordering using up/down arrows
Hi all,
I have a list of records (videos) that are ordered using a value in a field called 'theorder'. 1 is at the top of the list. When the user clicks up or down next to each of the videos then it takes its current position and either +1 or -1 from it, and whatever is in that position switches values with it. Here is my code: PHP Code:
I'm sure there is a much better way of doing this - can anybody point me in the right direction? Thanks |
Well, when you delete a record, you need to set all the other records after the deleted record's order to order-1. Example: say you have 5 items. The item with the id 3 has the order number 2. After you issue the delete statement, run this aswell:
Code:
UPDATE items SET theorder=theorder-1 WHERE theorder > deleted_record_order |
| All times are GMT. The time now is 02:19 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0