如何将php变量传递给bootstrap模式?

时间:2016-01-09 12:01:11

标签: javascript php jquery twitter-bootstrap

我在网上看,我不明白它是如何运作的。我想将一个php变量传递给bootstrap模态。但是,我似乎无法做到这一点。我想将$ data [' idPerson']值传递给模态..

这是我的HTML代码:

<table class="table table-striped projects">
    <thead>
         <tr>
             <th style="width: 5%">ID</th>
             <th style="width: 15%">Resident</th>
             <th style="width: 15%">Date of Payment</th>
             <th style="width: 10%">Subtotal</th>
             <th style="width: 10%">Request Progress</th>
             <th style="width: 5%">Status</th>
             <th style="width: 10%">Action</th>
          </tr>
     </thead>                                   
 <?php
      include('config.php');
      $display = mysqli_query($conn, "SELECT idPerson, firstName, middleName, lastName, docrequest_date, typeOfDoc, isPartOfTotal, paymentStatus, cedulaNumber, ri.price FROM person p LEFT JOIN documentrequest dr ON p.idPerson = dr.Person_idPerson LEFT JOIN requestitem ri ON dr.idDocumentRequest = ri.DocumentRequest_idDocumentRequest LEFT JOIN document d ON d.idDocument = ri.Document_idDocument WHERE d.typeOfDoc =  'Cedula' AND ri.paymentStatus =  'Paid' AND cedulaNumber = 0");

      while($data = mysqli_fetch_array($display)){

  ?>

  <tbody>
      <tr>
          <td><?php echo $data['idPerson'];?></td>
          <td><?php echo $data['firstName'].' '.$data['middleName'].' '.$data['lastName'];?></td>
        <td> <?php echo $data['docrequest_date'];?> </td> 
        <td> <?php echo $data['isPartOfTotal'];?> </td>
        <td class="project_progress">
        <div class="progress progress_sm">
             <div class="progress-bar bg-green" role="progressbar" data-transitiongoal="85"></div>
        </div>
        <small>85% Complete</small>
        </td>
        <td><span class="label label-success">Paid</span></td>
        <td class=" ">
            <a class="btn btn-primary btn-xs modal-box" id = "insert" href="insertModal" data-toggle="modal"><i class="fa fa-edit m-right-xs" name="edit"></i> Add Cedula Number</a> //WHEN I CLICK THIS, A MODAL WILL APPEAR AND PASS THE VALUE OF $
        </td>
      </tr>

  </tbody>
<?php
}
echo mysqli_error($conn);
 ?>
</table>

这是模态代码:

<div class="modal fade" id="insertModal" tabindex="-1" role="dialog" aria-labelledby="memberModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header" style="background-color: #CE5454; color: white;">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="memberModalLabel">Add Cedula Details</h4>
            </div>
            <div class="modal-body">
                <h5>GET THE idPerson value!!!</h5>
                <BR>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
            </div>
        </div>
    </div>
</div>

jquery代码:

<script>
    $("#insert").click(function () {
        $('#insertModal').modal('show');
    });
</script>

我该怎么做?请帮忙。谢谢!!

0 个答案:

没有答案