Make me cry made me smile MySQL Delete record operation code with PHP

Source: Internet
Author: User
Tags mysql delete mysql delete record administrator password
First we create a new data display page view.php:

Copy the Code code as follows:


$link =mysql_connect ("localhost", "root", "Administrator Password");
mysql_select_db ("Infosystem", $link);
$q = "SELECT * from Info";
mysql_query ("SET NAMES GB2312");
$rs = mysql_query ($q, $link);
echo "




"; echo " "; while ($row = Mysql_fetch_object ($rs)) echo " "; echo "
Department Name Employee Name PC Name
Id ' >del $row->depart $row->ename
";
?>


Unlike the General Data display page, this time there is a "Del" connection before each record, and by clicking del we can delete the corresponding data record in MySQL. The meaning of the red part of the program is: When you click del, the ID number of the corresponding record is passed to dodel.php.
Next look at dodel.php:

Copy the Code code as follows:


$link =mysql_connect ("localhost", "root", "Administrator Password");
mysql_select_db ("Infosystem", $link);
$del _id=$_get["id"];
$exec = "Delete from info where id= $del _id";
mysql_query ($exec, $link);
echo "Delete succeeded!";
Mysql_close ($link);
?>


This page is the key to this topic, it receives the ID number from view.php, and it is used to delete the record of the SQL statement, so as to achieve the purpose of deleting the record.
Let's take a look at the SQL statements for MySQL data removal:
Delete from table name WHERE Condition = value
The value here is received by $del_id=$_get["id"], passed to the SQL statement, and finally executed by mysql_query to execute the SQL statement.
OK, can you confirm that the data in MySQL has been deleted correctly? If you have any questions, you can just leave a message to ask ~
Author: Sunec
Original download: Cenus Blog

The above describes the make me cry makes me smile the MySQL Delete record operation code with PHP, including content made me cry makes me smile, I hope to be interested in PHP tutorial friends helpful.

  • Related Article

    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.