Bootstrap 在页面上使用多个超链接的模式

Bootstrap Modal Using Multiple Hyperlinks on a Page

我使用 bootstrap 模式打开弹出模式,以便设置我的帐户权限。当我点击第一个 link 时,它会准确打开。但是当我点击任何其他 link。以前的数据再次显示。我已经尝试了很多次,但仍然没有成功。

这是加载整个列表的 Table 的代码:

<table class="table table-bordered table-striped table-hover">
    <tr>
    <th>Code</th>
    <th>Name</th>
    <th>Authorities</th>
    <th>Password</th>
    <th>Status</th>
    </tr>
<?php
foreach($res as $data) {
    ?>
    <tr>
        <td><?php echo $data[INST_CODE]; ?></td>
        <td><?php echo $data[INST_NAME]; ?><?php echo "  ($insttype)"; ?></td>

        <td><a data-toggle="modal" data-target="#myModal" class="btn btn-info" href="auth2.php?inst_code=<?php echo $data[INST_CODE]; ?> ">Authorities</a></td>
    </tr>
<?php
}
?>
</table>

模态代码如下:

<div id="myModal" class="modal fade" role="dialog">
    <div class="modal-dialog">

        <!-- Modal content-->
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="modal-title">Modal Header</h4>
            </div>
            <div class="modal-body">
                <p>Some text in the modal.</p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
        </div>

    </div>
</div>

auth2.php 包含要显示的内容。请指导我

在 for 循环中创建模态代码并为每个元素提供一个动态 ID <td><a data-toggle="modal" data-target="#myModal1" class="btn btn-info" >Authorities</a></td> <td><a data-toggle="modal" data-target="#myModal2" class="btn btn-info" >Authorities</a></td> . . . 等等

模态代码会有不同的id,每个都会在for循环中

在模态调用按钮所在页面放置如下脚本

<script>
//jQuery Library Comes First
//Bootstrap Library
$(document).ready(function() {
    $('#myModal').on('hidden.bs.modal', function () {
          $(this).removeData('bs.modal');
    });
});
</script>

它会在关闭时删除以前的数据,并在打开模态时加载新数据点击下一行模态按钮。