拖放排序带数据库的完整版本,更新后为最新的排序
ajax.php
PHP Code
- $result0 = $_REQUEST["table-3"];
- $result=array_splice($result0,1);
- //print_r($result);
- //$num=count($result)-1;
- //取得原来的排序,只要排序就行了
- $rs=mysql_query("select * from content order by sort");
- while($row = mysql_fetch_array($rs))
- {
- $rows .= $row['sort'].",";
- }
- $str=substr($rows, 0, -1);
- $array_old_paixu=split(",",$str);
- for($resultnum=0;$resultnum<count($result);$resultnum++) {
- //echo $result[$resultnum];//要替换的id
- //echo $array_old_paixu[$resultnum];//排序值
- $update_sql="UPDATE content SET `sort` = '".$array_old_paixu[$resultnum]."' WHERE `id` = $result[$resultnum]";
- $resultx = mysql_query($update_sql);
- }
原文地址:http://www.freejs.net/article_jquerywenzi_551.html