I have the following table on my page view_feedback.php
//Retrieve feedback info from database
$query = $db->prepare("SELECT * FROM feedback ORDER BY ID desc");
$query->execute();
//Display feedback info in table
echo "<table id='user' class='table table-bordered'>
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Email</th>
<th>Message</th>
</tr>
</thead>";
while ($dbRow = $query->fetch(PDO::FETCH_ASSOC)) {
$id = $dbRow['ID'];
$name = $dbRow['Name'];
$email= $dbRow['Email'];
$message = $dbRow['Message'];
{ echo "<tr>
<td>$id</td>
<td>$name</td>
<td>$email</td>
<td>$message</td>
<td>" . " <input type='submit' action='view_feedback.php' id= '$id' . ' value='Delete' >" . "</td>
</tr>"
;}
}
echo "</table>";
And then i have this code to execute the delete:
if (isset($_POST['delete'])){
$query = $db->prepare (DELETE * FROM feedback WHERE ID = ?)
$query->execute($id);
}
The table displays fine but when i click the delete button nothing happens?
<input type='submit' action='view_feedback.php' id= '$id' . ' value='Delete' >
它应该有一个名称='delete',以便$ _POST可以检索它:
<input type='submit' name = 'delete' action='view_feedback.php' id= '$id' . ' value='Delete' >
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.