使用Jquery拖放将记录插入到mysql中

时间:2017-08-18 06:55:12

标签: jquery drag-and-drop sql-update

当我将列表项从一个拖放到另一个时,我需要插入/更新记录。 一切都很好,列表项被拖放,但我无法更新数据库记录。

有人可以帮我吗?非常令人沮丧。

我有四个<ul>标签:

<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.js"></script>


<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<style>
    #sortable0,
    #sortable1,
    #sortable2,
    #sortable3 {
        list-style-type: none;
        float: left;
        padding: 0px;
        width: 143px;
        min-height: 60px;
        text-align: left;
    }

    #sortable0 {
        height: 10px !important;
    }
</style>

<script>
    $( function () {
        $( "ul.droptrue" ).sortable( {
            connectWith: "ul",
            cursor: "move"
        } );

        $( "ul.dropfalse" ).sortable( {
            connectWith: "ul",
            dropOnEmpty: false
        } );

        $( "#sortable0, #sortable1, #sortable2, #sortable3" ).disableSelection();
    } );
</script>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<div id="response"> </div>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="6">
    <tr>
        <td>
            <?php 

        echo $_POST['sortie_id'];


        ?>
        </td>
    </tr>
</table>
<table width="100%" border="0" cellpadding="4" cellspacing="4">
    <form>
        <tbody>
            <tr>
                <td width="65%" nowrap="nowrap">Bir Sonraki Sorti :
                    <strong>
                        <?php echo $nextSortie; ?>
                    </strong>
                </td>
                <td width="33%" align="center" nowrap="nowrap">Yolcu Say&#305;s&#305; :
                    <strong>
                        <?php echo $num_nSortieDetails; ?>
                    </strong>
                </td>
                <td width="35%" align="right" nowrap="nowrap">
                    <?php
                    // print the passenger list for the sortie
                    $pa = new PrintAnything();



                    $url = ( !isset( $_SERVER[ 'HTTPS' ] ) || $_SERVER[ 'HTTPS' ] != 'on' ? 'http://' : 'https://' );
                    $url .= $_SERVER[ 'HTTP_HOST' ] . dirname( $_SERVER[ 'PHP_SELF' ] );
                    $url = trim( str_replace( '\\', '/', $url ) );
                    if ( substr( $url, -1 ) != '/' ) {
                        $url .= '/';
                    }
                    $url .= 'print_SortieList.php';
                    $printData3 = PrintAnything::readBody( $url );
                    $con3 = $pa->addPrintContext( $printData3 );

                    $pa->showPrintLink( $con3, '<button style="font-size:24px">Yazdır <i class="fa fa-print"></i></button>' );

                    //  end print stuff

                    ?>
                </td>
            </tr>
            <tr>
                <td colspan="3" align="center" nowrap="nowrap">
                    <hr width="90%" size="1" color="#FFFFFF"/>
                </td>
            </tr>
            <tr>
                <td colspan="2" nowrap="nowrap" bgcolor="#FFFFFF" width="65%" valign="top">

                    <div id="list">
                        <?php if($num_nSortieDetails > 0) { 

          ?>

                        <ul id="sortable0" class="droptrue">

                            <?php
                            do {
                                ?>

                            <li class="ui-state-default" id="arrayorder_<?php echo $id ?>">
                                <span class="noshow">
                                    <?php echo $row_nSortieDetails['id']; ?> </span>
                                <span class="psgr">
                                    <?php echo ucwords(strtolower($row_nSortieDetails['fullname'])); ?>
                                </span>
                            </li>

                            <?php 
          } while($row_nSortieDetails=mysqli_fetch_array($nSortieDetails));
    ?>
                        </ul>
                        <?php
                        } // end if the recordset has results ?>
                    </div>
                </td>
                <td width="35%" valign="top" nowrap="nowrap" bgcolor="#F4CDCD">
                    <?php echo "pilot out : " . $pilot_out;
            ?>
                </td>
            </tr>
            <tr>
                <td colspan="3" nowrap="nowrap" bgcolor="#FFFFFF" valign="top">&nbsp;</td>
            </tr>
            <tr>
                <td colspan="3" nowrap="nowrap" bgcolor="#FFFFFF" valign="top">
                    <table width="75%" border="0" cellspacing="7" cellpadding="2" align="center">
                        <tbody>
                            <tr>
                                <td align="center"><strong>Ocean Team</strong>
                                </td>
                                <td align="center"><strong>Dragon Team</strong>
                                </td>
                                <td align="center"><strong>Albatros Team</strong>
                                </td>
                            </tr>
                            <tr>
                                <td align="center" valign="top">
                                    <ul id="sortable1" class="droptrue">

                                    </ul>
                                </td>
                                <td align="center" valign="top">
                                    <ul id="sortable3" class="droptrue">

                                    </ul>
                                </td>
                                <td align="center" valign="top">
                                    <ul id="sortable2" class="droptrue">

                                    </ul>
                                </td>
                            </tr>
                            <tr>
                                <td align="left" valign="top">
                                    <?php $ops->TeamPilots("1", $db); ?>
                                </td>
                                <td align="left" valign="top">
                                    <?php $ops->TeamPilots("2", $db); ?>
                                </td>
                                <td align="left" valign="top">
                                    <?php $ops->TeamPilots("3", $db); ?>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </td>
            </tr>
        </tbody>
    </form>
</table>

<br style="clear:both">

我想从'sortable0'拖到三个中的任何一个

我希望拖动的记录ID在相关数据库中更新。

提前感谢您的帮助

0 个答案:

没有答案