Delete multiple records at once with a CheckBox _php tutorial

Source: Internet
Author: User
Answer a friend question: How to delete multiple records at once.
A simple example
Existing student information database, need to delete more than one record at a time
Create a file named del.php

The code is as follows:

Copy to ClipboardWhat to refer to: [www.bkjia.com]

This file is mainly used to display the data in the database and show it.

Then create a file named Sc.php, where the code is as follows:

Copy to ClipboardWhat to refer to: [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 error occurred while deleting";
Exit
}
else{
echo "Student information has been deleted";
}
}
Mysql_close ();
?>

The records are deleted in a foreach manner, respectively.

Source: http://www.cnblogs.com/walkbro/

http://www.bkjia.com/PHPjc/364481.html www.bkjia.com true http://www.bkjia.com/PHPjc/364481.html techarticle answer a friend question: How to delete multiple records at once. A simple example existing a student information database, need to delete multiple records at once create a file named Del.php ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.