html 模态与 php 和 mySql

问题描述 投票:0回答:1

尝试找到解决我的问题的方法 我有2张桌子...

第一个包含客户 ID 和姓名、电话、地址...等

第二个表包含客户交易,如 ID、发票编号、金额、日期...等

我制作 html 表包含客户 ID 和(模态)按钮...当单击此按钮时,应该弹出模态窗口并显示此客户交易(当然通过 SQL 过滤)

点击按钮时出现模态窗口不出现的问题........................ 问候

<?php
  include "dbConn.php";
?>
<html>
<head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
</head>

<table class="table table-bordered table-striped">
  <th>
    <tr class="btn-primary">
    <th>id</th>
    <th>Action</th>
  </tr>
  </th>
    <?php 
        $result = mysqli_query($conn,"select id  from customers ");
        while($row = mysqli_fetch_array($result)) 
        {
    ?>
  <tr>
    <td><?php echo $row['id']; ?></td>
    <td><button type="button" name = "filt" class="btn btn-info" data-toggle="modal" data-target="#myModal<?php echo $row['id'] ?>">Details</button></td>
  </tr>
<?php 
  }
?>
</table>
 
  <div id="myModal<?php 
    echo $row['id']; 
    $x= $row['id'];
    ?>" class="modal fade" role="dialog">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
             <button type="button" class="close" data-dismiss="modal">&times;</button>
            </div>
                <div class="modal-body">
                    <table class="table table-bordered table-striped" style=" border-collapse: collapse; width: 100%; margin-top : 60px; color: black; text-align: center;  "  border="4" >  
                    <tr>
                        <th   class="not_mapped_style" style="text-align:center"> ID </th>
                        <th   class="not_mapped_style" style="text-align:center"> Date</th>
                        <th   class="not_mapped_style" style="text-align:center">Reference</th>    
                        <th   class="not_mapped_style" style="text-align:center">Amount</th>    
                    </tr>
                        <?php 
                        $records = mysqli_query($conn,"select * from trans where id =  $x  ");  
                        while($data = mysqli_fetch_array($records))
                        {
                        ?>
                        <tr>
                         <td> <?php echo $data['id']; ?></td>
                         <td> <?php echo $data['date']; ?></td>
                         <td> <?php echo $data['invNO']; ?></td>
                         <td> <?php echo $data['amount']; ?></td>
                        </tr>           
                        <?php
                            }
                        ?>  
                    </table>
                </div>
            </div>
        </div>
    </div>
php modal-dialog
1个回答
0
投票

如果在 body 关闭之前加载 js 文件,它的性能是否会更好?

© www.soinside.com 2019 - 2024. All rights reserved.