我正在尝试删除数据库中的一行,同时从网址获取它的ID exmaple exmaple.com /deteteTeam.php?Id=? <<这是从单选按钮选项中选择的id,当选择像Id = 1时,它将等于数字。
include ('connnect.php');
// this connect my database and working
$command = "DELETE * FROM SoccerPoll WHERE Id=?";
$stmt = $dbh ->prepare($command);
$stmt->execute($_GET['Id']);
答案 0 :(得分:1)
在尝试执行que query之前,您可以使用bindParam或bindValue。
$command = " DELETE FROM SoccerPoll WHERE Id=:id LIMIT 1";
$stmt = $dbh ->prepare($command);
$stmt->bindParam(':id', $_GET['Id'], PDO::PARAM_INT);
$stmt->execute();
答案 1 :(得分:0)
删除将按以下方式执行
$sql = "DELETE FROM movies WHERE filmID = :filmID";
$stmt = $pdo->prepare($sql);
$stmt->bindParam(':filmID', $_GET['filmID'], PDO::PARAM_INT);
$stmt->execute();