What's wrong? {Code...} is not correct?
prepare("delete from class where name=?"); $stmt2->execute(array($_POST['name'])); } ?>
Reply content:
What's wrong?
prepare("delete from class where name=?"); $stmt2->execute(array($_POST['name'])); } ?>
You write this code strangely.
First, why can't I delete it:
Your input box does not have the value attribute. Therefore, your $ _ POST ['name'] cannot get the value.
You can change it
echo ''.$v['name'].'';
Then I look at your code. do you want to delete multiple choices? Then you need to submit an array to php by post, then you can modify the name attribute of input:
echo ''.$v['name'].'';
The post received by php is as follows:
$name = $_POST['name'];//array(name1,name2....)
In this case, you need to process this $ name. Change your SQL statement
delete from class where name in (name1,name2,name3...)
For example:
$sql = "delete from class where name in (" . trim(str_repeat('?,',count($name)),',') . ")";$stmt2 = $pdo->prepare($sql);$stmt2->execute($name);
Then, you 'd better judge the is_post code before the output list. otherwise, output the code first and then delete the code. The result is not displayed.
Is this the first entry?