hello,
Im following a few tutorials to sort a list, but i can't get the DB to update. The drag drop side of things is working, also, i javascript alert() the serialize list onUpdate and the order is printed out as follows:
images_list[]=20&images_list[]=19
etc...
So the sorting and dragging is working fine, i just cant get the database to update, this is my code.
<script type="text/javascript">
Sortable.create("images_list", {
onUpdate: function() {
new Ajax.Request("processor.php", {
method: "post",
parameters: { data: Sortable.serialize("images_list") }
});
}
});
processor.php code:
//Connect to DB
require_once('connect.php');
parse_str($_POST['data']);
for ($i = 0; $i < count($images_list); $i++) {
$id = $images_list[$i];
mysql_query("UPDATE `images` SET `ranking` = '$i' WHERE `id` = '$id'");
}
Any ideas would be great, thankyou!