我正在尝试在数据库中允许雇员的删除。我已将查询字符串存储到名为$ id的变量中。当我运行SQL DELETE语句时,它回显了,但没有回显或识别出我实例化的$ id变量。有什么想法吗?
PHP
//QUERY STRING
"<td><a href='delete.php?id=" . $row['empid'] . "'>Delete</a></td>" .
//ID VARIABLE
$id = (isset($REQUEST['id']) ? $_REQUEST['id'] : '');
SQL
//SQL STATEMENT
$sql = "DELETE FROM employees WHERE empid= '" . $id . "';";
//WHAT ECHOS OUT IS BELOW
echo($sql);
//RUN SQL Command
mysqli_query($connect,$sql) or die(mysql_error());
print("User " . $id . " deleted from the database.");
print("Return to <a href='index.php'>Return To Main Page</a>");
从员工那里删除empid ='';
当我单击index.php中的delete时,我尝试删除的员工仍然在那里。
答案 0 :(得分:3)
您需要更改此行
$id = (isset($REQUEST['id']) ? $_REQUEST['id'] : '');
到
$id = (isset($_REQUEST['id']) ? $_REQUEST['id'] : '');