将数据发送到bootstrap模式并执行mysql查询

时间:2014-08-08 05:32:36

标签: javascript php jquery mysql twitter-bootstrap

    while($row = mysqli_fetch_array($result_from_query)){   
     <a class="modal-trigger" href="#basicModal" data-toggle="modal" data-target="#basicModal" data-id="<?php echo $row['invoice_no']; ?>"><?php echo $row['invoice_no']; ?>
        </a>
}

<div class="modal fade" id="basicModal" tabindex="-1" role="dialog" aria-labelledby="basicModal" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                    <h5 class="modal-title" id="myModalLabel">Invoice Item</h4>
                    </div>
                    <div class="modal-body">
                        <input type="text" name="invoice" id="invoice" value=""/>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                    </div>
                </div>
          </div>
        </div>

 <script type="text/javascript">
            $(document).on("click", ".modal-trigger", function () {
             var invoiceNO = $(this).data('id');
             $(".modal-body #invoice").val( invoiceNO );
        });
        </script>

所以我有这个代码将数据发送到模态并将其放入<input name="invoice" /> 现在我的问题是我想把它放在一个php变量中,以便在#basicModal div中的查询中使用它。 像这样的东西

<div class="modal fade" id="basicModal" tabindex="-1" role="dialog" aria-labelledby="basicModal" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                    <h5 class="modal-title" id="myModalLabel">Invoice Item</h4>
                    </div>
                    <div class="modal-body">
                        <?php 
                             $result = mysqli_query($conn, 'SELECT item from invoice_tab where invoice no = ' $invoice_no);
                             $data = mysqli_fetch_assoc($result);
                             echo $data['item'];
                        ?>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                    </div>
                </div>
          </div>
        </div>

但我不知道如何将数据放入php变量......你能不能帮助我... tnx

1 个答案:

答案 0 :(得分:0)

你为什么不用你的:

$row['invoice_no'];

在你的第一个例子中填写模态中的SQL查询?