栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

jQuery UI保存可排序列表

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

jQuery UI保存可排序列表

$("#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);}

应该这样做,我没有测试它,因为它是一个示例连接。我实际使用的实际脚本更特定于我的程序,这是显示概念的简化版本



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/416622.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号