$("#list").live('hover', function() { $("#list").sortable({ update : function () { var neworder = new Array(); $('#list li').each(function() { //get the id var id = $(this).attr("id"); //create an object var obj = {}; //insert the id into the object obj[] = id; //push the object into the array neworder.push(obj); }); $.post("pagewhereyouuselist.php",{'neworder': neworder},function(data){}); } }); });然后在您的PHP文件中,或在此示例中为“ pagewhereyouuselist.php”
$neworderarray = $_POST['neworder'];//loop through the list of ids and update your dbforeach($neworderarray as $order=>$id){ //you prob jave a connection already i just added this as an example $con = mysql_connect("host","username","password"); if (!$con){ die('Could not connect: ' . mysql_error()); } mysql_select_db("my_db", $con); mysql_query("UPDATE table SET order = {$order} WHERe id = {$id}"); mysql_close($con);}应该这样做,我没有测试它,因为它是一个示例连接。我实际使用的实际脚本更特定于我的程序,这是显示概念的简化版本



