我正在尝试从 sql 中创建一个删除按钮。我启动了一个名为 $del 的函数,但我不知道如何完成它,其形式是在当前回显语句旁边回显一个删除按钮。
$con = mysql_connect("localhost", "user", "pass");
if (!$con) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("database", $con);
$sql = "INSERT INTO camps (city, map, park, day, details)
VALUES ('$_POST[city]','$_POST[map]','$_POST[park]','$_POST[day]','$_POST[details]')";
if (!mysql_query($sql, $con)) {
die('Error: ' . mysql_error());
}
$number = 0;
$del = mysql_query("DELETE FROM camps WHERE user_id= '$number'");
$result = mysql_query("SELECT * FROM camps");
while ($row = mysql_fetch_array($result)) {
echo "<a href=\"'" . $row['map'] . "\">" . $row['city'] . "</a>";
echo "<br />";
}