A little knowledge:
1, PHP access to the database, additions and deletions to the database, the page display results = Database results
2, <radio><checkbox><option> label, Name= "xx[]", which indicates how many commits are selected and submitted as an array, which can be obtained in array form.
Value values are defined by themselves, with different <text> value.
The value is obtained by the name submission.
Bulk Delete:
Click the button to achieve bulk deletion, need a form form, need a batch processing page (also can put the same page, but also need to add code, to achieve the initial effect).
Main Page code:
<form action= "plsc.php" method= "post" ><?PHP$db=NewMysqli ("localhost", "root", "123", "info");!Mysqli_connect_error() or die("Connection Failed");$sql= "SELECT * FROM Info";$result=$db->query ($sql);$attr=$result-Fetch_all ();foreach($attr as $v){ $s=$v[2]==1? ' Male ': ' Female '; $sq= "SELECT name from Nation where Code= ' {$v[3]} ' "; $r=$db->query ($sq); $a=$r-Fetch_row (); Echo"<tr> <td align= ' center ' ><input type= ' checkbox ' name= ' xx[] ' value= '$v[0] ' class= ' a '/>{$v[0]}</td> <td align= ' center ' >{$v[1]}</td> <td align= ' center ' >{$s}</td> <td align= ' center ' >{$a[0]}</td> <td align= ' center ' >{$v[4]}</td> <td align= ' center ' ><a href= ' delete.php?code={$v[0]} ' > Delete </a> <a href= ' update.php?code={$v[0]} ' > Modify </a> </td> </tr>";}><TR><TD align= "center" ><input type= "checkbox" onclick= "Checkall (This)"/> Select all </td></ TR><TR><TD align= "center" ><input type= "submit" value= "Bulk Delete"/></td></tr></form >
Processing page:
<?PHPHeader("Content-type:text/html;charset=utf-8");if(!Empty($_post)){ $xx=$_post["XX"];//one-dimensional arrays Var_dump($xx); //Operational Database Removal $db=NewMysqli ("localhost", "root", "123", "info"); !Mysqli_connect_error() or die("Connection Failed"); //choose which one to delete the article /*foreach ($xx as $v) {$sql = "Delete from info where code= ' {$v} '"; $result = $db->query ($sql, 0); }*/ for($i= 0;$i<=Count($xx);$i++) { $sql= "Delete from info where code= ' {$xx[$i]}‘"; Var_dump($sql); $result=$db->query ($sql); Var_dump($result); } if($result) { Header("location:main.php"); } Else { Echo"Bulk Delete Failed"; }}
Case: Bulk Delete