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

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...