用户注销后,它基本上会删除其表中包含任何行中id代码的所有数据。
$idcode = $_SESSION['idcode'];
$idicao = $_SESSION['idicao'];
if(isset($_POST['logout'])) {
$sql = "DELETE FROM $idicao WHERE idcode=".$idcode."";
mysql_query($sql);
}
session_unset();
session_destroy();
mysql_close($dbid);
header("Location: login.php");
?>
变量在页面上正确回显,session_start位于顶部。唯一的问题是表中的记录没有被删除。
答案 0 :(得分:2)
更改此行:
$sql = "DELETE FROM $idicao WHERE idcode=".$idcode."";
到
$sql = "DELETE FROM ".$idicao." WHERE idcode=".$idcode.";
你应该好好去
答案 1 :(得分:2)
试试这个:
$idicao='yourtablename';
$sql = 'DELETE FROM '.$idicao.' WHERE idcode='.$idcode;
答案 2 :(得分:1)
你说的是sql-variable输出:DELETE FROM Test WHERE idcode = test
测试应该是单引号,如下所示:
$sql = "DELETE FROM ".$idicao." WHERE idcode='".$idcode."'";
答案 3 :(得分:0)
$query = 'DELETE FROM ? WHERE idcode = ?';
$stmt = $db->prepare($query);
$stmt->bind_param('ss', $idicao, $idcode);
$stmt->execute();
if (mysqli_connect_errno()) {
$obj->error = 'Error: ...your error msg...';
echo json_encode($obj);
exit;
}