PHP + MySQL delete operation instance

Source: Internet
Author: User
Tags mysql delete
This article mainly introduces the methods for deleting PHP + MySQL, and analyzes the tips for deleting MySQL information. It has some reference value. For more information, see

This article mainly introduces the methods for deleting PHP + MySQL, and analyzes the tips for deleting MySQL information. It has some reference value. For more information, see

This article describes how to use PHP + MySQL to delete objects. Share it with you for your reference. The details are as follows:

The Code is as follows:


Delete record
<? Php
// Database connection Parameters
$ 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, delete it.
If (isset ($ _ GET ['id']) {
// Construct the SQL statement for deleting records
$ Query = "delete from symbols WHEREid =". $ _ GET ['id'];

// Execute SQL query
If ($ mysqli-> query ($ query )){
// Display the number of affected records after deletion
Echo $ mysqli-> affected_rows. "row (s) affected ";
}
Else
{
// If no matching record exists, the error message returned by the database is displayed.
Echo "Error in query: $ query.". $ mysqli-> error;
}
}
// Create and display deleted records
$ Query = "SELECT * FROM symbols ";
// Execute this query
If ($ result = $ mysqli-> query ($ query )){
// Display the number of returned Record Sets
If ($ result-> num_rows> 0 ){
// If a record exists
// Display the content of columns in the record set
Echo"






















I hope this article will help you with php programming.

";While ($ row = $ result-> fetch_array ()){Echo" ";Echo" ";Echo" ";Echo" ";Echo" ";Echo" ";}}// Release the memory occupied by the object$ Result-> close ();}Else{// Output database error informationEcho "Error in query: $ query.". $ mysqli-> error;}// Close the 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.