我想从数据库中删除选定的数据。在删除之前,我会询问用户确认,如果他同意仅会基于member_id删除数据库中的数据。为此,我希望将值包括在页面(deleteUser.php)中。 我知道如何使用表单和href将变量从一页传递到另一页。但是,这里我没有得到如何传递变量的信息。
有人可以帮助我吗?
然后我将通过while循环获取member_id,例如$ userdetails ['member_id'];。在代码中,
我可以这样使用。但是我只想使用上面的代码。
01 | 2500DXG S LEFT | Available | http://....pdf | 96,000 | 814,000
......
我的代码是
<a href="http://localhost/Performance/login/deleteUser.php?" class="delete" name="delete" data-toggle="modal"><i class="material-icons" data-toggle="tooltip" title="Delete" Onclick="return ConfirmDelete()"></i></a>
我的deleteUser.php代码
<?php
include_once "deleteUser.php";
?>
<table class="table table-striped table-hover">
<thead>
<tr>
<th>
<span class="custom-checkbox">
<input type="checkbox" id="selectAll">
<label for="selectAll"></label>
</span>
</th>
<th>Username</th>
<th>Email</th>
<th>Role</th>
</tr>
</thead>
<tbody>
<?php
while($userdetails = mysqli_fetch_array($res, MYSQLI_ASSOC)){
echo' <tr>
<td>
<span class="custom-checkbox">
<input type="checkbox" id="checkbox1" name="options[]" value="1">
<label for="checkbox1"></label>
</span>
</td>
<td>'.$userdetails['username'].'</td>
<td>'.$userdetails['email'].'</td>
<td>'.$userdetails['role'].'</td>
<td>
<a href="#editEmployeeModal" class="edit" data-toggle="modal"><i class="material-icons" data-toggle="tooltip" title="Edit"></i></a>
<a href="#deleteEmployeeModal" class="delete" name="delete" data-toggle="modal"><i class="material-icons" data-toggle="tooltip" title="Delete"></i></a>
</td>
</tr>';
}?>
</tbody>
</table>
<div id="deleteEmployeeModal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<form method="post" action="#" method="post" autocomplete="off">
<div class="modal-header">
<h4 class="modal-title">Delete Employee</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
<p>Are you sure you want to delete these Records?</p>
<p class="text-warning"><small>This action cannot be undone.</small></p>
</div>
<div class="modal-footer">
<input type="button" class="btn btn-default" data-dismiss="modal" value="Cancel">
<input type="submit" class="btn btn-danger" name="deleteUser" value="Delete">
</div>
</form>
</div>
</div>
</div>
答案 0 :(得分:0)
尝试一下。
if(isset($_POST['deleteUser'])){
$member_id = $_POST['options'];
// write delete sql query here
}