我正在编写一个函数,如果它已经存在,它将删除一个表。它将询问用户他们想调用什么表,获取该响应并将其放入 php 变量中。我想为 sql 创建一个自定义的 drop 语句,以便 sql 没有错误。这就是我所拥有的。
$table = $_POST["tablename"]; //gets table name from html page
drop_table($db, $table); //call function
function drop_table($db,$table){
$drop = "DROP TABLE IF EXISTS .$table. "; //this is the part I can't figure out. How do I add in the table name to the statement,
$q = mysqli_query($db, $drop); //since the sql statement has to be in quotes?
}
谢谢!
P.Ss 这是一个仅用于分析的内部系统。如果我和我的同事都在使用它,不用担心丢桌子