Serialize sortable string to MySQL database using PHP?
I did a quick search on the group and found a few examples, but
nothing is working for me.
I have something like...
<ul id="photoTable">
<li id="item-1"><img src="sections/portraiture/thumbnails/p01.png" /></
li>
<li id="item-2"><img src="sections/portraiture/thumbnails/p02.png" /></
li>
<li id="item-3"><img src="sections/portraiture/thumbnails/p03.png" /></
li>
</ul>
I'd like to re-order the photos, and then Save (or effective put the
new order into a string) to a MySQL database.
There was one post which totally seemed to conceptual work, but it
failed on the first line...
It was a post from John Luxford, but the list = $('#sortable-list
li'); fails, and I tried similar things, but nothing is working.
I was hoping there was going to be an easy way to get this string to a
database, or at least a .txt file.
Thanks.
---------------
Here's what worked for me (after googling for the answer myself a
while back). First, set up the items so they each have an id
attribute like this:
<ul id="sortable-list">
<li id="item-1">Item 1</li>
<li id="item-2">Item 2</li>
</ul>
Where 1 and 2 are their unique IDs behind-the-scenes. Next, your
callback function would work like this:
function sortable_callback () {
list = $('#sortable-list li');
new_order = [];
for (var i = 0; i < list.length; i++) {
id = list[i].getAttribute ('id').replace ('item-', '');
new_order.push (id);
}
// now send new_order to the server...
}