我有这行代码:
$search = mysqli_query($mysqli, "SELECT * FROM list WHERE ID= '$name' ");
我想这样做:
$example = $mysqli->prepare('SELECT * FROM list (ID) VALUES (?)');
但是问题是我需要输入"mysqli_query($mysqli,"
部分,如何将其添加到第二行代码中?
答案 0 :(得分:0)
使用预备语句时,SQL语法不会更改。您只需将变量替换为占位符即可。
$statement = $mysql->prepare("SELECT * FROM list WHERE ID= ? ");
$statement->bind_param("s", $name);
$statement->execute();