PHP-mysqli Delete Data (sql delete row)

PHP-mysqli Delete Data (sql delete row)

PHP-mysqli Delete Data (sql delete row)

 

 

<?php
/*
http://www.w3schools.com/php/php_mysql_delete.asp
*/
$servername = “localhost”;
$username = “username”;
$password = “password”;
$dbname = “myDB”;

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die(“Connection failed: ” . $conn->connect_error);
}

// sql to delete a record
$sql = “DELETE FROM MyGuests WHERE id=3”;

if ($conn->query($sql) === TRUE) {
echo “Record deleted successfully”;
} else {
echo “Error deleting record: ” . $conn->error;
}

$conn->close();
?>

 

 

發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *