Tuesday, 20 February 2018

PHP MySQL Delete Record

Delete statement:
delete statement is used to delete records from a table
Syntax: 
delete form table name
Or
DELETE  FROM table_name
WHERE some_column = some_value
Example:
delete from emp where id=101;

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 = "delete from emp where id=101"; 

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

mysqli_close($con);
?>
Output:
Connected successfully
Record deleted 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...