PHP MySql Delete

PHP Have Query Method for all types of SQL Operations.

MySQL Delete (Object Oriented)


<?php

$server="localhost";
$username="root";
$password="";
$db="e-commerce";

$conn=new mysqli($server,$username,$password,$db);

if($conn->connect_error){
	die("Error:".$conn->connect_error);
}

$DeleteQuery="DELETE FROM Customers WHERE CustomerID=1";
 
$result=$conn->query($DeleteQuery);
if($result===true){
	echo 'Successfully Record Deleted.';
}else{
	echo 'Error:'.$conn->error;
}

$conn->close();
?>

MySQL Delete (Procedural)


<?php

$server="localhost";
$username="root";
$password="";
$db="e-commerce";

$conn=mysqli_connect($server,$username,$password,$db);

if(!$conn){
	die("Error:".mysqli_connect_error());
}
 
$DeleteQuery="DELETE FROM Customers WHERE CustomerID=1";
 
$result=mysqli_query($conn,$DeleteQuery);
if($result===true){
	echo 'Successfully Record Deleted.';
}else{
	echo 'Error:'.mysql_error($conn);
}


mysqli_close($conn);
?>