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

apply function in R

1) apply function: It takes 3 arguments matrix,margin and function.. Example: m<-matrix(c(1,2,3,4),nrow=2,ncol=2) m #1 indicates it is ap...