当前位置: 首页 > 知识库问答 >
问题:

如何修复PHP中的语法错误“意外”)

黄锋
2023-03-14

我在下面的代码中的Foreach循环中遇到错误,有人能帮我修复错误吗。。。

<form method="post" action="<?php  echo $_SERVER['PHP_SELF'];?>">

<?php



$dbc=mysqli_connect("localhost","root","","elvis_store") or die("Error Connecting to Mysql Database");

if(isset($_POST['submit'])){

foreach($_POST['todelete'] as delete_id){

$query="DELETE FROM email_list WHERE id=$delete_id";
mysqli_query($dbc,$query) or die("Error Querying Database");

}

echo "Customer(s) Removed";


}



$query="SELECT * FROM email_list";
$result=mysqli_query($dbc,$query)or die("Query Syntaxt is Incorrect");

while($row=mysqli_fetch_array($result)){

echo '<input type="checkbox" value="'.$row['id'].'" name="todelete[]"/>';
echo $row['first_name']." ".$row['last_name']." ".$row['email'];
echo "<br/>";




}



mysqli_close($dbc);




?>

<input type="submit" name"submit" value="Remove"/>




</body>

共有1个答案

孙成益
2023-03-14

我想错误一定是由于这一行:

foreach($_POST['todelete'] as delete_id){

替换为:

foreach($_POST['todelete'] as $delete_id){
 类似资料: