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:
<ul id="item_list" >
<li id="item_1">Item One</li>
<li id="item_2">Item Two</li>
<li id="item_3">Item Three</li>
<li id="item_4">Item Four</li>
</ul>
jQuery:
$("#item_list").sortable({stop:function(i) {
$.ajax({
type: "GET",
url: "server_items_reorder.php",
data: $("#item_list").sortable("serialize")
});
foreach($_GET['item'] as $key=>$value) {
mysql_query("UPDATE my_items" SET position = '" . $key . "' WHERE id ='" . $value . "'");
But I do this, it throws an error: show invalid arguement for foreach. What's wrong?