1.http://www.isocra.com/2008/02/table-drag-and-drop-jquery-plugin/
<script type='text/javascript' src='jquery-1.4.2.min.js'></script>
<script type='text/javascript' src='jquery.tablednd_0_5.js'></script>
<script type='text/javascript'>
$(document).ready(function(){
$('#tbl').tableDnD();
});
</script>
<form action='index.php' method='post'>
<table id='tbl'>
<tbody>
<tr id='1'><td><input type='hidden' name='new_sort[1]'></td></tr>
<tr id='2'><td><input type='hidden' name='new_sort[2]'></td></tr>
<tr id='n'><td><input type='hidden' name='new_sort[n]'></td></tr>
</tbody>
</table>
<input type='hidden' name='op' value='save_sort'>
<input type='submit' value='儲存排序'>
</form>
if($_POST['op']=="save_sort"){
$sort=1;
foreach($_POST['new_sort'] as $sn => $v){
$sql = "update 資料表 set `排序欄位` = '{$sort}' where 流水號='$sn'";
mysql_query($sql);
$sort++;
}
}
<style>
.myDragClass { color: yellow; background-color: black;}
</style>
$('#tbl').tableDnD({
onDragClass:"myDragClass"
});
$('#tbl').tableDnD({
onDragClass:"myDragClass" ,
onDragStart: function(table) {
$("#saveArea").html("<input type='hidden' name='op' value='save'><input type='submit' value='儲存'>");
}
});
<div id="saveArea" style="text-align:center;"></div>