我有一个bootstrap模式,我试图通过GET将唯一值传递给模态,但模态保持获得相同的唯一值,而不是我单击的表行的值。几天来一直苦苦挣扎,似乎无法弄清楚为什么它不起作用。代码在
之下<?php
$sql = "SELECT * FROM houses";
$q=$conn->query($sql);
while ($row = mysqli_fetch_array($q)) {
?>
<tr>
<td><?php echo $row['nickname']; ?></td>
<td><?php echo $row['state']; ?></td>
<td><?php echo $row['city']; ?></td>
<td><?php echo $row['address']; ?></td>
<td>
<div class="btn-group">
<a class="btn btn-success" href="view_property.php?house=<?php echo $row['nickname']; ?>"><i class="icon_check_alt2"></i></a>
<a class="btn btn-primary" href="edit_property.php?house=<?php echo $row['nickname']; ?>"><i class="icon_plus_alt2"></i></a>
<a class="btn btn-danger" data-toggle="modal" data-target="#myDelete"><i class="icon_close_alt2"></i></a>
</div>
<div id="myDelete" 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">×</button>
<h4 class="modal-title">Delete Property</h4>
</div>
<div class="modal-body">
<p>Are you sure you want to pull out this property from your list of Properties, as all data regarding this property will be lost permanently <?php echo $row['nickname']; ?></p>
</div>
<div class="modal-footer">
<a class="btn btn-success" href="view_property.php?house=<?php echo $row['nickname']; ?>">Delete</a>
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
</div>
</div>
</div>
</div>
</td>
答案 0 :(得分:0)
HTML
ID应该是唯一的,每次迭代都使用相同的id。
尝试使用:
id="myDelete<?php echo $row['id'] ?>"
data-target="#myDelete<?php echo $row['id'] ?>"
希望这有帮助!