Insert Data in MySQL Database
0 4543
As you read, How to Create Data. Now there is insertion Syntax after creating DATABASE. 'INSERT' statement is used to insert data into table.
MySQL Insert Data Syntax:
INSERT INTO table_name (column1, column2, column3) VALUES (value1, value2, value3);
Where table_name is the name of table in which we want to insert data and column1, column2 and column3 is the name of the fields in the table table_name and value1, value2 and value3 are the values of the particular columns.
Example:
<?php
$conn=mysqli_connect("localhost","root","","databasename");
$sql="INSERT INTO student(name, emailid, city) VALUES('Vihaan','vihaan@codingtag.com','Delhi')";
// student is table name
$result=mysqli_query($conn,$sql);
if ($result)
{
echo "Record Created Successfully";
}
else
{
echo "Insertion Failed";
}
?>
 
Share:

 
 
 
 



 
Comments
Waiting for your comments