title: JQuery UI Saving Sortable List
body: <p>I know this question has been asked before but the solutions did not work for me. I am trying to save the new ordering of items to the database.</p>
  
  <p>I have simplified it very considerably but this is the basic idea of it. I have a form with a sortable list embedded in it.</p>
  
  <pre><code>&lt;form id="itemlist"&gt;
      &lt;ul id="itemsort"&gt;
         &lt;li id="Item_1"&gt;Item&lt;input type="hidden" name="itemid[]" value="itemsRowID01"/&gt;&lt;/li&gt;
         &lt;li id="Item_2"&gt;Item&lt;input type="hidden" name="itemid[]" value="itemsRowID02"/&gt;&lt;/li&gt;
         &lt;li id="Item_3"&gt;Item&lt;input type="hidden" name="itemid[]" value="itemsRowID03"/&gt;&lt;/li&gt;
         &lt;li id="Item_4"&gt;Item&lt;input type="hidden" name="itemid[]" value="itemsRowID04"/&gt;&lt;/li&gt;
      &lt;/ul&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>I have JQuery and JQuery UI Loaded and the The Following code enables the sortable list function and posts the item ids and New sort order to a php script. the "editor" variable is a public variable that is set on load it works fine. The sorting works fine but the neworder value that posts doesn't seem to change when I re-order the list.</p>
  
  <pre><code>//sorting feature  
      $("#itemsort").live('hover', function() {
          $("#itemsort").sortable({ 
              opacity:.5,
              update : function () {          
  
                  var neworder =  $('#itemsort').sortable('serialize');
                  var inputs = serializePost('#itemlist');
  
                  $.post("core/actions.php",{
                     'order': editor,
                     'inputs': inputs,
                     'neworder': neworder},function(){
  
                         alert("Order saved.", 1);
  
                  });
              } 
          });
      });
  </code></pre>
  
  <p>On actions.php...</p>
  
  <pre><code>    if(isset($_POST['order'])){
  
              //set a variable for each post
              $batchid = $_POST['inputs']['itemid'];
  
              parse_str($_POST['neworder'], $neworder);
  
              //count the number of entries to be ordered
              $count = count($batchid);        
  
              //use the count to create an incremental loop for each item to be updated.
              $i=0;
              while ($i &lt;= $count) {
  
     $query ="UPDATE {$_POST['order']} SET order=$neworder[item][$i] WHERE id=$batchid[$i]";
                  ++$i;
              }
          }
  </code></pre>
  
  <p>I'm not sure why the order I get for each item will not change.</p>
  
  <p>Any Ideas?</p>
  
  <p>-L</p>