title: Update the sort order in a database using PHP from the jQuery sortable plugin
body: <p>I am using a jQuery plugin to sort the product order. It's working fine on the client site but I also want to update the order in the database. Here is my attempt: HTML:</p>
  
  <pre><code>&lt;ul id="item_list" &gt;
  &lt;li id="item_1"&gt;Item One&lt;/li&gt;
  &lt;li id="item_2"&gt;Item Two&lt;/li&gt;
  &lt;li id="item_3"&gt;Item Three&lt;/li&gt;
  &lt;li id="item_4"&gt;Item Four&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>jQuery:</p>
  
  <pre><code>$("#item_list").sortable({stop:function(i) {
    $.ajax({
      type: "GET",
      url: "server_items_reorder.php",
      data: $("#item_list").sortable("serialize")
    });
    foreach($_GET['item'] as $key=&gt;$value) {
      mysql_query("UPDATE my_items" SET position = '" . $key . "' WHERE id ='" .         $value . "'");
  </code></pre>
  
  <p>But I do this, it throws an error: show invalid arguement for foreach. What's wrong?</p>