首页 > 解决方案 > 将 php 文件回显到模式中的模式中 | PHP

问题描述

我有这个 php 页面。我正在努力寻找解决方案,因为每当我在模式中调用此页面时,它都不会显示。

我对此进行了几处更改,例如更改代码中单个元素的引用,更改回显结构,并修改为 all 只是为了让我能够回显它,但所有这些都没有运气。

这是我的收益_amendment_table.php

<?php include 'backend/session.php'; ?>
<?php 
if(isset($_POST['referenceno']))
$id=$_POST['referenceno'];
$sql = "select credit, debit, referenceid, datedue,
referenceno, earningsamendment.employeeidno, earningsamendment.accounttitle, earningsamendment.postedby, approvedby,
notedby,employeemasterfile.lastname,employeemasterfile.firstname,employeemasterfile.middlename,
earningsamendment.particulars,earningsamendment.accounttype
from earningsamendment
left join employeemasterfile on earningsamendment.employeeidno= employeemasterfile.employeeidno
where referenceno='$id' order by datedue desc";
    $query = sqlsrv_query($conn, $sql, array(), array("Scrollable" => SQLSRV_CURSOR_KEYSET));

    $out = "
    <div class='box-body'>
        <table id='earnings_amendment_view' class='table table-bordered' style='table-layout: fixed; display: table'>
            <thead>
                <th></th>
                  <th>Reference ID.</th>
                  <th>Reference No.</th>
                  <th>Employee Name</th>
                  <th>Account Title</th>
                  <th>Amount</th>
                  <th>Activity</th>
                  <th>Posted By</th>
                  <th>Validated By</th>
                  <th>Noted By</th>
                  <th>Tools</th>
                </thead>
            <tbody>
    ";

    while($row = sqlsrv_fetch_array($query, SQLSRV_FETCH_ASSOC)){
                      echo "
                      <tr data-key-1=".$row['particulars']." data-key-2=".$row['accounttype']." data-key-3=".$row['datedue'].">
                        <td class='details-control'></td>
                          <td>".$row['referenceid']."</td>
                          <td>".$row['referenceno']."</td>
                          <td>".$row['lastname']." ".$row['middlename']." ".$row['firstname']."</td>
                          <td>".$row['accounttitle']."</td>
                          <td>".$row['credit']."</td>
                          <td>".(($row['debit']==$row['credit']) ? 'PAID' : 'FOR TAKE UP' )."</td>
                          <td>".$row['postedby']."</td>
                          <td>".$row['approvedby']."</td>
                          <td>".$row['notedby']."</td>
                        </tr>
                      ";
                    }

    $out .= '
            </tbody>
        </table>
        </div>
    ';

    echo $out;
?>

这个脚本正在被这个模态调用者从 Earnings_amendment.php调用

$(function(){
$("body").on('click', '.edit', function (e){
        e.preventDefault();
        var id = $(this).data('id');
        $.ajax({
            type: 'post',
             url: 'earnings_amendment_table.php',
            data: {referenceno:id}
        }).done(function(d){
            //console.log('d: '+d);
            $('#earnings_amendment_table_').html(d);
            $('#earnings_amendment_table_').show();
        });
    });
});

与答题器一起,仍然在同一页面内 ( income_amendment.php )

    $("body").on('click', '.select', function (e){
    e.preventDefault();
    $('#select').modal('show');
    var id = $(this).data('id');
    getRow(id);
$(".modal:visible").modal('toggle');
  });

这是桌子

function format ( dataSource ) {
    var html = '<table cellpadding="5" cellspacing="0" border="0" style="padding-left:50px;" class="table table-bordered">';
    for (var key in dataSource){
        html += '<tr>'+
                   '<td>' + key             +'</td>'+
                   '<td>' + dataSource[key] +'</td>'+
                '</tr>';
    } return html += '</table>';  }
var earnings_amendment_employee_view_table = $('#earnings_amendment_view').DataTable({});
      $('#earnings_amendment_view').on('click', 'td.details-control', function () {      var tr = $(this).closest('tr');
          var row = earnings_amendment_employee_view_table.row(tr);
          if (row.child.isShown()) {
              row.child.hide();
              tr.removeClass('shown');
          } else {
              // Open this row
              row.child(format({
                  'Particulars : ' : tr.data('key-1'),
                  'Account Type : ' : tr.data('key-2'),
                  'Date Due : ' :  tr.data('key-3')
              })).show();
              tr.addClass('shown');
          } });

而且,这是调用它的模态。

这是income_amendment_modal.php

<!-- Edit -->
<div class="modal fade" id="edit">
    <div class="modal-dialog" style="width:95%">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title"><b>Update Founder Data</b></h4>
            </div>
            <div class="modal-body">
                <form autocomplete='off'  class="form-horizontal" method="POST" action="earnings_amendment_edit.php">
                    <input type="hidden" class="decid" name="id">
                    <input type="hidden" name="year" value="<?php echo $year; ?>">
                    <input type="hidden" name="accounttitle" value="<?php echo $accounttitle; ?>">
                <input type="hidden" class="decid" name="id">
                <!-- Table Loader -->
                <div class="form-group" id="earnings_amendment_table_"><div class="col-sm-9" id="earnings_amendment_table_" style="width:100%">
                </div></div>    
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default btn-flat pull-left" data-dismiss="modal"><i class="fa fa-close"></i> Close</button>
                </form>
            </div>
        </div>
    </div>
</div>

这里似乎有什么问题?因为我的模态调用者设置正确。

<!-- Table Loader -->
                <div class="form-group" id="earnings_amendment_table_"><div class="col-sm-9" id="earnings_amendment_table_" style="width:100%">
                </div></div>    

它只显示这个。

图片

我试图通过故意在表中执行错误来检查它,并且错误正确显示。

我假设这个问题的主要原因是这条线。

echo "
                      <tr data-key-1=".$row['particulars']." data-key-2=".$row['accounttype']." data-key-3=".$row['datedue'].">
                        <td class='details-control'></td>
                          <td>".$row['referenceid']."</td>
                          <td>".$row['referenceno']."</td>
                          <td>".$row['lastname']." ".$row['middlename']." ".$row['firstname']."</td>
                          <td>".$row['accounttitle']."</td>
                          <td>".$row['credit']."</td>
                          <td>".(($row['debit']==$row['credit']) ? 'PAID' : 'FOR TAKE UP' )."</td>
                          <td>".$row['postedby']."</td>
                          <td>".$row['approvedby']."</td>
                          <td>".$row['notedby']."</td>
                        </tr>
                      ";

因为我已经有一个变量持有者$out应该把所有东西放在一起。

这有转机吗?提前致谢。

标签: phpjqueryajaxbootstrap-modal

解决方案


推荐阅读