我一直在关注本教程 从 html 页面删除 mysql 行的最佳方法 - 删除链接和 php
但我被卡住了,我的行不会删除。请帮忙
// My Viewing dish Page
<?php
$result = mysql_query("SELECT * FROM dish");
echo "<table border='1'>
<tr>
<th>DishID</th>
<th>DishName</th>
<th>DishPrice</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['DishID'] . "</td>";
echo "<td>" . $row['DishName'] . "</td>";
echo "<td>" . $row['DishPrice'] . "</td>";
echo '<td><a href="delete.php?id=' . $row['DishID'] . '">Delete</a></td>';
echo "</tr>";
}
echo "</table>";
?>
//Delete Page
<?php
require_once("database.php");
/*
DELETE.PHP
Deletes a specific entry from the 'players' table
*/
// check if the 'id' variable is set in URL, and check that it is valid
if (isset($_GET['DishID']) && is_numeric($_GET['DishID']))
{
// get id value
$DishID = $_GET['DishID'];
// delete the entry
$result = mysql_query("DELETE FROM dish WHERE DishID =$DishID} ")
or die(mysql_error());
// redirect back to the view page
header("Location: admin_modifydishes.php");
}
else
// if id isn't set, or isn't valid, redirect back to view page
{
echo "doesn'twork";
}
?>
我相信这与 $DishID = $_GET['DishID']; 有关。但我无法绕过它,请帮助。