Sortable with scriptaculous problems

Posted by user195257 on Stack Overflow See other posts from Stack Overflow or by user195257
Published on 2010-06-16T23:09:39Z Indexed on 2010/06/16 23:12 UTC
Read the original article Hit count: 184

Filed under:

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!

© Stack Overflow or respective owner

Related posts about scriptaculous