我试图创建一个函数,当按下按钮时,PHP会从数据库中删除该记录。正在使用正确的ID重定向网站,并且DeleteID变量中包含正确的值,但由于某种原因,我无法将其删除以删除记录
Delete.PHP
<?php
session_start();
//get value of ?id= from the url
$DeleteID = $_GET['id'];
echo $DeleteID;
require("connect.php");
//Linking
$link = connectToDB();
//SQL Query
$sql = "DELETE
FROM tbl_property
WHERE propetyid = $DeleteID";
//Execute
$result = $link->query($sql);
//Check
if ($link->affected_rows == 1) {
echo "Worked";
echo "<a href='properties.php'> SIGH </a>";
}
else {
echo "Didn't Work";
echo "<a href='properties.php'> SIGH </a>";
}
?>
表格
答案 0 :(得分:0)
您输入propetyid
而不是propertyid
的字段名称存在拼写错误
$sql = "DELETE
FROM tbl_property
WHERE propetyid = $DeleteID";