jQuery UI's sortable plugin to update a database table's sort order field on the fly using ajax basically, tutorial is here.
http://www.petefreitag.com/item/736.cfm
Seemed like the perfect tutorial for what I am doing.
Basically I have a bunch of sortables using jquery, they are unordered lists containing list items all with an ID that's basically listitemthing_1 all the way to 85.
This tutorial shows how to 'save' their order (even a button with "save" or on the fly..)so next time you visit the page, or when the page is reloaded all the list items are in their appropriate sortables.
The sortables I'm dealing with (Very simple):
$(function() {
$("#sortable1, #sortable2, #sortable3, #sortable4, #sortable5, #sortable6, #sortable7, #sortable8, #sortable9, #sortable10").sortable({
connectWith: '.connectedSortable'
}).disableSelection();
});
Basically, the php side of things is what I needed to understand because I wanted the values kept track of (or something with a hidden field..)
<cfparam name="url.fruitOrder" type="string">
<!--- fruitOrder = fruit_1,fruit_2, etc...--->
<cfset order = 0>
<cfloop list="#url.fruitOrder#" index="item">
<cfset fruit_id = Val(ListLast(item, "_"))>
<cfset order = order+1>
<cfquery>
UPDATE fruit
SET sort_order = <cfqueryparam value="#order#" cfsqltype="cf_sql_integer">
WHERE fruit_id = <cfqueryparam value="#fruit_id#" cfsqltype="cf_sql_integer">
</cfquery>
<cfoutput>#fruit_id#</cfoutput>
</cfloop>
Is the Coldfusion code for the tutorial but since our web host won't install it I'm in a pickle.
(I just took over the site, the guy before me signed us up with Hostpapa)
How can I do this with just php?