Tuesday, 20 February 2018

PHP MySQL Update Record

Update statement
Update statement is used to update existing records in a table
Syntax: 
UPDATE table_name
SET column1=value, column2=value2,...
WHERE some_column=some_value 
Example:
update emp set name="dev" where name="Dipak";

Example:
<?php
$servername= 'localhost’;
$username = 'root';
$password = '';
$dbname='lp'
$con = mysqli_connect($servername, $username, $password,$dbname);
if(! $con )
{
  die('Could not connect: ' . mysqli_error());
}
echo 'Connected successfully';

$sql ='update emp set name="dev" where name="Dipak" '; 

if(mysqli_query($con, $sql)){ 
 echo "Record updated successfully"; 
}
else{ 
echo "Could not update record: ". mysqli_error($con); 
} 

mysqli_close($con);
?>
Output:
Connected successfully
Record updated successfully

No comments:

Post a Comment

Global Infrastructure and its components in AWS

You may operate your workloads wherever and however you choose with the AWS Global Infrastructure, and you'll use the same network, cont...