Php+mysql Delete an instance of an operation, phpmysql delete an example _php tutorial

Source: Internet
Author: User
Tags mysql delete

Php+mysql Delete operation instance, phpmysql Delete instance


The examples in this article describe the use of php+mysql delete operations. Share to everyone for your reference. Specific as follows:

Copy the Code code as follows:

Deleting records


<?php
Parameters for connecting to a database
$host = "localhost";
$user = "root";
$pass = "zq19890319";
$db = "Phpdev";
Create a Mysqli object
Open a database connection
$mysqli = new Mysqli ($host, $user, $pass, $db);
Check for connection errors
if (Mysqli_connect_errno ()) {
Die ("Unable to connect!");
}
If the record ID exists, the delete operation is performed
if (Isset ($_get[' id ')) {
Constructing SQL to delete records
$query = "DELETE from symbols Whereid =". $_get[' id '];

Execute SQL query
if ($mysqli->query ($query)) {
Show the number of records affected after deletion
Echo $mysqli->affected_rows. "Row (s) affected";
}
Else
{
Displays the error message returned by the database if there are no matching records
echo "Error in Query: $query.". $mysqli->error;
}
}
Construct to display deleted records
$query = "SELECT * from symbols";
Execute the query
if ($result = $mysqli->query ($query)) {
Shows the number of recordset rows returned
if ($result->num_rows>0) {
If there is a record
Display the contents of columns in a recordset
echo "




















I hope this article is helpful to everyone's PHP programming.

http://www.bkjia.com/PHPjc/945698.html www.bkjia.com true http://www.bkjia.com/PHPjc/945698.html techarticle Php+mysql Delete operation instance, Phpmysql Delete instance This article describes the use of the php+mysql delete operation. Share to everyone for your reference. As follows: Copy code code such as ...

  • "; while ($row = $result->fetch_array ()) {echo " "; echo " "; echo " "; echo " "; echo " "; echo " "; }}//Releases the memory occupied by the object $result->close (); } else {//Output database error message echo "Error in Query: $query.". $mysqli->error; }//Close database $mysqli->close ();?>
    ". $row [0]."". $row [1]."". $row [2]."Delete

    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.