Insert Data in MySQL Database | Coding Tag
×

Insert Data in MySQL Database

3846

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";
}
?>



Best WordPress Hosting


Share:


Discount Coupons

Get a .COM for just $6.98

Secure Domain for a Mini Price



Leave a Reply


Comments
    Waiting for your comments