테이블의 특정 레코드를 삭제하는 데 문제가 있습니다. 현재 내가 한 것은 삭제와 편집을위한 두 가지 형식을 만드는 것입니다. 어떤 이유로, 삭제 된 원하는 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');
//
?>
코드를 공유하십시오. –
일부 코드를 알려주십시오. 우리는 얇은 공기에서 응답을 발명 할 수 없습니다. – Jerodev
이 (가) 게시물을 업데이트했습니다. 죄송합니다! –