【发布时间】:2019-05-28 21:06:47
【问题描述】:
希望一切都好,做得最好。 我们可以通过在每一行中都有一个按钮来删除 PHP 中的特定行,所以如果我们没有在每一行中都有一个删除按钮,只需使用一个删除按钮来删除特定行,我们可以如何做到这一点。更多信息请查看上传的图片。
<div class="modal fade" id="modalDelete" tabindex="-1" role="dialog"
aria-labelledby="modalDelete" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header text-center">
<h4 class="modal-title w-100 font-weight-bold ml-5 text-
danger">Delete</h4>
<button type="button" class="close text-danger" data-dismiss="modal"
aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body mx-3">
<p class="text-center h4">Are you sure to delete selected record?</p>
</div>
<div class="modal-footer d-flex justify-content-center
deleteButtonsWrapper">
<button type="submit" name="btnDeleteRec" class="btn btn-danger
btnYesClass" id="btnYes">Yes</button>
<button type="submit" class="btn btn-primary btnNoClass" id="btnNo" data-
dismiss="modal">No</button>
</div></div></div></div>
<table id="dtBasicExample" class="table table-striped table-bordered"
cellspacing="0" width="100%">
<thead>
<tr>
<th class="th-sm" style="width:20px; text-align:center;">ID</th>
<th class="th-sm" style="width:150px; text-align:center;">Name</th>
<th class="th-sm" style="width:150px; text-align:center;">Position</th>
<th class="th-sm" style="width:200px; text-align:center;">Image</th>
<th class="th-sm" style="text-align:center;" ><i style="margin-
right:10px;" class="fa fa-facebook" aria-hidden="true"></i>Facebook</th>
<th class="th-sm" style="text-align:center;"><i style="margin-
right:10px;" class="fab fa-twitter"></i>Twitter</th>
<th class="th-sm" style="text-align:center;"><i style="margin-
right:10px;" class="fa fa-google-plus" aria-hidden="true"></i>Google Plus
</th></tr></thead>
<tbody>
<?php
while($datarecord=mysqli_fetch_assoc($resultrecord))
{
?>
<tr>
<td style="text-align:center;"><?php echo $datarecord["id"]; ?></td>
<td style="text-align:center;"><?php echo $datarecord["name"]; ?></td>
<td style="text-align:center;"><?php echo $datarecord["position"]; ?>
</td>
<td style="text-align:center;">
<?php
echo '<img src="images/'.$datarecord['image'].'" style="height:60px;
width:65px;">';
?>
</td>
<td style="text-align:center;"><?php echo $datarecord["facebook"]; ?>
</td>
<td style="text-align:center;"><?php echo $datarecord["twitter"]; ?></td>
<td style="text-align:center;"><?php echo $datarecord["googleplus"]; ?>
</td>
</tr>
<?php
}
?>
【问题讨论】:
-
表示你想像选择和删除?
-
是的,选择行后按删除按钮变为删除
-
将复选框放在 id 旁边并在选中复选框上使用 ajax 调用删除选中的复选框
-
看到我不想使用任何复选框,只是当我单击该行时必须选择和删除没有任何复选框有什么办法。
-
使用
checkbox或selecting a row并不重要。两者的代码相同。更改仅on select of checkbox或on select of row
标签: javascript php jquery html css