我有一个数据库中的项目表,每个项目我都需要一个删除按钮。
目前它正在工作,但按钮显示 ID 号,我希望它只说“删除”。
我仍然希望它根据 joke.ID 删除
$result = mysqli_query($con, "SELECT joke.id, joketext, jokedate, name, email FROM joke INNER JOIN author ON authorid = author.id");
echo "<form action='delete1.php' method='post'>
<table border='1'>
<tr>
<th>Joke</th>
<th>Date</th>
<th>Name</th>
<th>Email</th>
<th>Delete</th>
</tr>";
while( $row = mysqli_fetch_array( $result ) ) {
echo "<tr>";
echo "<td>" . $row['joketext'] . "</td>";
echo "<td>" . $row['jokedate'] . "</td>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['email'] . "</td>";
echo "<td><input type='submit' name='deleteItem' value='".$row['id']."' /></td>";
echo "</tr>";
}
echo "</table>";
echo "</form></br>";
mysqli_close($con);
?>
这是delete1.php
if ( isset( $_POST['deleteItem'] ) and is_numeric( $_POST['deleteItem'] ) ) {
// here comes your delete query: use $_POST['deleteItem'] as your id
mysqli_query($con,"DELETE FROM joke WHERE id='$_POST[deleteItem]'");
}
mysqli_close( $con );
header('Location: joke1.php');
exit();
?>
我只想让按钮说“删除”