首页 > 解决方案 > 捕获传递的模态值并将其转换为 php 查询参数

问题描述

编辑:我可以寻求有关此代码的帮助吗?

这是我的模态。我的输入文本收到AAA-123-0001的值

该脚本通过以下方式包含在主页中include()

<input type="hidden" class="decid" id="id" name="id">
<?php include 'includes/services_payslip_list_payslip-selection.php'; ?>

这是我的 services_payslip_list_payslip-selection.php

<script>
  $(document).ready(function() {
  $("#id").change(function() {
    var id = $(this).val();
    if(id != "") {
      $.ajax({
        url:"services_payslip_list-payslip-table.php",
        data:{id:id},
        type:'POST',
        success:function(response) {
          var resp = $.trim(response);
          $("#id").html(resp);
        }
      });
    }
  });
</script>

这是我的 services_payslip_list-payslip-table.php

<table id="example2" class="table table-bordered">
<thead>
<th>Schedule Date</th>
<th>Schedule Name</th>
<th>Recorded In</th>
<th>Recorded Out</th>
<th>Day Count</th>
<th>Day Value</th>
<th>N.D. Value</th>
<th>Leave Count</th>
<th>R.H. Count</th>
<th>R.H. Value</th>
</thead>
<tbody>

<?php 
include 'includes/session.php';
if(isset($_POST['id'])) {
$id=$_POST['id']
}
$user = $user['fingerscanno'];
$sql = "SELECT fingerscanno, scheduledate, schedulename, recordin, recordout, noofdays, rate, nightdifferential, leaveday, regularholiday, specialholiday, referenceno

FROM payrollrecords WHERE fingerscanno='$user' and referenceno='$id'";

                    $query = sqlsrv_query($conn, $sql, array(), array("Scrollable" => SQLSRV_CURSOR_KEYSET));
                    while($row = sqlsrv_fetch_array($query, SQLSRV_FETCH_ASSOC)){

 echo "
                        <tr>
                          <td>".$row['scheduledate']."</td>
                          <td>".$row['schedulename']."</td>
                          <td>".$row['recordin']."</td>
                          <td>".$row['recordout']."</td>
                          <td>".$row['noofdays']."</td>
                          <td>".$row['rate']."</td>
                          <td>".$row['nightdifferential']."</td>
                          <td>".$row['leaveday']."</td>
                          <td>".$row['regularholiday']."</td>
                          <td>".$row['specialholiday']."</td>
                        </tr>
                      ";
}

                  ?>
                </tbody>
              </table>

这里似乎有什么问题?services_payslip_list_payslip-selection.php 不会加载到模式中。

标签: phphtmlmodal-dialogsqlsrv

解决方案


推荐阅读