可排序会扰乱我的数据库排序

I am using Jquery UI as a frontend and PHP with MYSQL as a backend. My problem arises when I open the sort page for the first time, it messes up my entire order. For example:

id|text|orderid|
----------------  
1 |abc |2      |  
2 |bca |4      |  
3 |zxc |6      |  
4 |qwe |3      |  
5 |ads |1      |  
6 |iul |5      |  

becomes:

id|text|orderid|
----------------
1 |abc |5      |  
2 |bca |1      |  
3 |zxc |3      |  
4 |qwe |6      |  
5 |ads |4      |  
6 |iul |2      |  

my index.php(HTML+JS): http://pastebin.com/5F66ncVF
my updatedb.php(PHP&mysql queries): http://pastebin.com/3zhRvgvB

Please Help?

Haven't had time to really go through your data but this is what I use to get my data on my ajax call:

var data = $('ol.sortable').nestedSortable('toHierarchy', {startDepthCount: 1});

I explicitly set the handle and items so sortable knows where to get the data from:

$('ol.sortable').nestedSortable({
    handle: 'div',
    items: 'li',
    ...

For debugging, I send data to this using console.log(data);

//for nested sortable
function dump(arr,level) {
    var dumped_text = "";
    if(!level) level = 0;

    //The padding given at the beginning of the line.
    var level_padding = "";
    for(var j=0;j<level+1;j++) level_padding += "    ";

    if(typeof(arr) == 'object') { //Array/Hashes/Objects
        for(var item in arr) {
            var value = arr[item];

            if(typeof(value) == 'object') { //If it is an array,
                dumped_text += level_padding + "'" + item + "' ...
";
                dumped_text += dump(value,level+1);
            } else {
                dumped_text += level_padding + "'" + item + "' => \"" + value + "\"
";
            }
        }
    } else { //Strings/Chars/Numbers etc.
        dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
    }
    return dumped_text;
}

Maybe give that a try first and if not I can look into your code a bit further...