给出正确的URL,Mysql删除功能不起作用

时间:2017-05-27 12:17:31

标签: php mysql

我试图创建一个函数,当按下按钮时,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>";
}
?>

表格

enter image description here

1 个答案:

答案 0 :(得分:0)

您输入propetyid而不是propertyid的字段名称存在拼写错误

$sql = "DELETE
          FROM tbl_property
          WHERE propetyid = $DeleteID";