<form method= "POST" action= "<?php$_server[' php_self '];?> ">//use self-referencing form, $_server[' php_self '] variable to display the PHP file's own filename<?PHP//connect to MySQL database$dbc=Mysqli_connect(' localhost ', ' root ', ' root ', ' test_store ') or die(' Error conneting to MySQL server. '));//determine if the form has been submittedif(isset($_post[' Submit '])){ foreach($_post[' Todelete '] as $delete _id){
//$_post[' Todelete ' is the todelete[] array, and the value of the selected check box will exist in this array $query= "Delete from email_list where id=$delete _id"; Mysqli_query($dbc,$query) or die(' ERROR delete data '.); } Echo"Email is removed.<br/>";}//querying email_list Data Sheets$query= "SELECT * FROM Email_list";$result=Mysqli_query($dbc,$query) or die(' ERROR select database. '));//Generate check box while($row=Mysqli_fetch_array($result) { //$result stores the entire data table to which the query is stored, while each time the $row array stores a row of data in the data table. Echo' <input type= ' checkbox ' value= '.$row[' ID ']. ' " Name= "todelete[]"/> "; //Note the Name property of the Chinese bracket Echo $row[' Email ']; Echo' <br/> ';}//to close a connection to a databaseMysqli_close($dbc);><BR/><input type= "Submit" name= "submit" value= "Submit" ></form>
PHP generates an array by setting the table cell Name property