我在刪除桌面上的某個記錄時遇到問題。我目前所做的是爲刪除和編輯創建兩個表單。出於某種原因,我無法獲得已刪除的所需ID。刪除桌面上的記錄
我嘗試回顯從該窗體傳遞的id的值。和通過的ID是13.
所以基本上我做了一個循環的行。我只是有問題從某一行獲取ID。
這裏是我的表的截圖。
這裏就是我使用的形式
customer.php
<div class="box-body table-responsive">
<form id='edit' action="functions/edit.php" method="post"></form>
<form id='delete' action="functions/delete.php" method="post"></form>
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>Actions</th>
<th>ID</th>
<th>User</th>
<th>Contact Number</th>
<th>Date Registered</th>
<th>Email</th>
<th>Organization</th>
<th>Address</th>
</tr>
</thead>
<tbody>
<?php
$Query = mysqli_query($conn, "SELECT * FROM customer");
while($row = mysqli_fetch_array($Query)){
echo "<tr>";
echo "<td><div class='btn-group'>
<button type='button' class='btn btn-info dropdown-toggle' data-toggle='dropdown'>Action
<span class='caret'></span>
<span class='sr-only'>Toggle Dropdown</span>
</button>
<ul class='dropdown-menu' role='menu'>
<li><button form='edit' class='btn' type='submit' name='edit' style='width: 100%;background-color: white;'>Edit</button></li>
<li><button form='delete' class='btn' type='submit' name='delete' style='width: 100%;background-color: white;'>Delete</button></li>
</ul>
</div>
</td>";
echo "<td>". "<input form='delete' type='hidden' name='id' value='" . $row['id'] . "'> " . $row['id'] . "</td>";
echo "<td>". $row['firstname'] . " " . $row['lastname'] . "</td>";
echo "<td>". $row['contact'] . "</td>";
echo "<td>". $row['date_reg'] . "</td>";
echo "<td><span class='label label-success'>" . $row['email'] . "</span></td>";
echo "<td>". $row['organization'] . "</td>";
echo "<td>". $row['address'] . "</td></tr>";
}
?>
</tbody>
<tfoot>
<tr>
<th>Actions</th>
<th>ID</th>
<th>User</th>
<th>Contact Number</th>
<th>Date Registered</th>
<th>Email</th>
<th>Organization</th>
<th>Address</th>
</tr>
</tfoot>
</table>
</div>
這裏是我的delete.php看起來像
<?php
include('config.php');
$deleteID = $_POST['id'];
//----- Check if user to be deleted is the user in session -----//
echo $deleteID;
// $deleteSQL = mysqli_query($conn, "delete from customer where id = '$deleteID'");
echo "<script type='text/javascript'>alert('Deleted succesfuly');</script>";
//header('Refresh: 0; url=../customers.php');
//
?>
分享您的代碼 – 2014-12-05 11:01:01
請給我們展示一些代碼。我們無法憑空發明答案。 – Jerodev 2014-12-05 11:01:14
更新了帖子。抱歉! – 2014-12-05 11:06:43