View Full Version : Reorder list of data
06-15-2010, 09:50 AM
I have a database with names of courses (its for a restaurant), they all have an ID which ranges from 1-8 (I only have 8 courses so far). I can add and delete courses from this table but I would like to be able to reorder theses courses, in other words change their ID, without having to go into the database and manually change itself.
06-15-2010, 10:01 AM
Could you please post the code that you've done so far?
06-15-2010, 10:13 AM
I don't actually have any code so far.. I was kinda hoping you could help me out with that....
06-15-2010, 11:19 AM
It is not too easy to envisage what you are trying to do. Please give an example of the "before" and "after".
You talk about a database. Surely this should be done server-side?
"This is the worst disaster in California since I was elected." - California Governor Pat Brown, discussing a local flood
06-15-2010, 11:32 AM
so say I have a list of data in my database that looks like this:
then I open up my page and change (which is want i want to do) the order in which they appear. So I drag/move/w.e the entries about so they look like this:
I'd now like to be able to add this new order to the database, but change the id of each course so that order will change
I hope this helps, im not the best at explaining sometimes =s
I don't think you want to change the ID - you need an additional column in your database table which displays the sort order. As per other posts this is going to need some server side stuff.
However, it's possible to do drag and drop with the aid of jQuery relatively simply , plus some AJAX to update your database - have a look at this (http://www.simonbattersby.com/blog/index.php/drag-and-drop-with-jquery-ui/) - it's for changing the display order of some images - but the idea's the same.
06-15-2010, 11:50 AM
awesome, thank you for that link, i shall give it a go now :)
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.