PHP MySql Update

PHP Have Query Method for all types of SQL Operations.

MySQL Update (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);
}

$UpdateQuery="UPDATE Customers SET PhoneNumber=03451234567 WHERE CustomerID=1";
 
$result=$conn->query($UpdateQuery);
if($result===true){
	echo 'Successfully Record Updated.';
}else{
	echo 'Erro:'.$conn->error;
}

$conn->close();
?>

MySQL Update (Procedural)


<?php

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

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

if(!$conn){
	die("Error:".mysqli_connect_error());
}

$UpdateQuery="UPDATE Customers SET PhoneNumber=03451234567 WHERE CustomerID=1";
 
$result=mysqli_query($conn,$UpdateQuery);
if($result===true){
	echo 'Successfully Record Updated.';
}else{
	echo 'Error:'.mysql_error($conn);
}


mysqli_close($conn);
?>