Insert statement:
Insert statement is used to insert data into table in MySQL
Syntax:
Syntax:
INSERT INTO table_name (column1, column2, column3,...)
VALUES (value1, value2, value3,...)
VALUES (value1, value2, value3,...)
Example:
INSERT INTO emp(id,name,salary)values(101,"Dipak",45500.78);
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 ='INSERT INTO emp(id,name,salary)values(101,"Dipak",45500.78)';
if(mysqli_query($con,
$sql)){
echo "Record inserted
successfully";
}
else{
echo "Could
not insert record: ". mysqli_error($con);
}
mysqli_close($con);
?>
Output:
Connected
successfully
Record inserted
successfully
No comments:
Post a Comment