如何解决Bootstrap Modal不适用于表中的所有记录
我已经制作了一个引导模式,用于使用PHP中的while循环分别更新表中的每个记录,但是它似乎仅适用于表的第一条记录。我无法弄清楚哪里出了问题。请帮助我,让我知道我要去哪里了。
这是代码:
<!DOCTYPE html>
<html>
<body>
<?PHP
$sql = "SELECT * FROM fee_status";
$result = $conn->query($sql);
$i = 1;
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
?>
<table>
<tr>
<td width='5%'><?PHP echo $i++; ?></td>
<td width='20%'><?PHP echo $row["student_id"]; ?><br><?PHP echo $row["student_name"]; ?></td>
<td width='10%'><?PHP echo $row["fee_due"]; ?></td>
<td width='25%'>
<div class="dropdown">
<button class='btn btn-primary dropdown-toggle' type='button' id='dropdownMenuButton' data-toggle='dropdown' aria-haspopup='true' aria-expanded='false'>Actions</button>
<div class='dropdown-menu' aria-labelledby='dropdownMenuButton'>
<a class='dropdown-item' data-toggle='modal' data-target="#myModal<?PHP echo $row['student_id']; ?>">Update Payment</a>
</div>
</div>
</td>
</tr>
</table>
<div class="modal" role="dialog" id="myModal<?PHP echo $row['student_id']; ?>">
<div class="modal-dialog" role="document" style="max-width: 65%;">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Update Payment</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form id="update_payment_form" class="form-group" action="update_fee.PHP" method="post">
<div class='form-group required'>
<div class="row">
<div class="col-md-6">
Student Details: <input type="text" name="student_details" value='<?PHP echo $row['student_id']; ?> - <?PHP echo $row['student_name']; ?>' style='width: 70%;' readonly>
</div>
</div>
<br>
<div class="row">
<div class="col-md-6">
Amount: <input type="number" name="new_payment" placeholder='<?PHP echo $row['fee_due']; ?>' style='width: 40%;' required>
</div>
</div>
<br>
<div class="row">
<div class="col-md-6">
Date: <input id="date-field" type="date" name="date" style='width: 40%;'>
</div>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" onclick="form_submit()" class="btn btn-primary">Update</button>
</div>
</div>
</div>
</div>
<?PHP
}
}
?>
</body>
</html>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。