The INSERT INTO statement is used to add new records to a database table. The insert statement is used to add new records to a database table. each time a new record is to be added we use INSERT INTO statement for that purpose. There are two ways of inserting records either explicitly providing the column name with values respectively or simply by providing values of the table but doesn't specify the column name.
The INSERT INTO statement is used to add new records to a MySQLi table:
INSERT INTO table_name (column1, column2, column3,...)VALUES (value1, value2, value3,...)
<?php
$host = "localhost";
$user = "";
$pass = "";
$dbname = "users";
$conn = mysqli_connect($host,$user,$pass,$dbname) or die(mysqli_error());
$sql = "INSERT INTO users(name,salary) VALUES ('suhail','90000')";
if(mysqli_query($conn,$sql)){
echo "Record inserted successfully";
}else{
echo "Could not insert record: ". mysqli_error();
}
mysqli_close();
?>
Record inserted successfully
© 2024 Easy To Learning. All Rights Reserved | Design by Easy To Learning