insert into mysql table code example

Example 1: Insert mysql

#Some columns or all 
INSERT INTO table_name (column1, column2, column3, ...)
VALUES (value1, value2, value3, ...);
#All columns
INSERT INTO table_name
VALUES (value1, value2, value3, ...);

Example 2: insert mysql

INSERT INTO tbl_name (a,b,c) 
    VALUES(1,2,3), (4,5,6), (7,8,9);

Example 3: insert into mysql

INSERT INTO "table_name" ("column1", "column2", "column3", ...)
VALUES ('value1', "value2", 'value3', ...);

Example 4: mysql insert mysqli

<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "database";
// Create connection
$conn = new mysqli($servername, $username, $password,$dbname);

// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?>Copy

Tags:

Php Example