Answer a friend’s question: How to delete multiple records at once.
A simple example
There is a student information database and multiple records need to be deleted at one time
Create a file named del.php
The code is as follows:
Copy to ClipboardQuoted content:
[www.bkjia.com]
This file is mainly used to display the data in the database and display it.
Create a file named sc.php with the following code:
Copy to ClipboardQuoted content:
[www.bkjia.com]
$link=mysql_connect("localhost","root","");
mysql_select_db("zs");
$id=$_POST['de'];
foreach($id as $ide){
$exec="delete from student where sID=$ide";
$result=mysql_query($exec);
if((mysql_affected_rows()== 0) or (mysql_affected_rows==-1))
{
echo "No record found, or an error occurred while deleting";
exit;
}
else{
echo "Student The information has been deleted";
}
}
mysql_close();
?>
Use foreach to delete the records respectively.
Source: http://www.cnblogs.com/walkbro/
http://www.bkjia.com/PHPjc/364481.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/364481.htmlTechArticleAnswer a friend’s question: How to delete multiple records at one time. A simple example: There is a student information database and multiple records need to be deleted at one time. Create a file named del.php...