我正在用 php 开发一个页面,该页面具有多个动态模式,用于在页面本身中显示具有各自标题和作者姓名的 pdf 文件。所有的数据都来自一个用 MySQL 设计的数据库。触发按钮也应该是动态的。我已经尝试了以下代码。问题是我让模态框空白。我能够在fetch-reader.php页面本身中打印数据。我认为我在AJAX或模态部分做错了什么。请指导我完成它。
<?php $sqlGal = "select * from articles where year = '2019'";
$queryGal = $con->query($sqlGal);
if ($queryGal->num_rows > 0) {
while ($row = $queryGal->fetch_array()) { ?>
<div class="col-md-3 gallery-grid">
<h3 style="height: 200px; vertical-align: bottom; margin: 0; display: table-cell;"><?php echo($row['title']) ?></h3>
by<h4><?php echo($row['name']) ?></h4>
<a href="#myReader" class="btn btn-success" id="readerID" data-toggle="modal" data-id="<?php echo($row['id']); ?>"> <i class="fa fas fa-book-open"></i> Read</a>
</div>
<?php }
}
?><div class="clearfix"></div>
<div class="modal fade" id="myReader" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h3 id="articleName"></h3>
<h4 id="name"></h4>
<h6 id="position"></h6>
<h6 id="address"></h6>
</div>
<div class="modal-body">
<object data="" id="reader" width="100%" height="450px"></object></div>
</div>
</div>
</div>
</div>
请指导我任何其他可以达到我目的的方式,但我不想为此目的使用任何第三方工具。
萧十郎