PHP MySqli Inserting Multiple Records at once example
<?php
$mysqli = new mysqli("localhost","root","","your_db",3306);
// Our table
// CREATE TABLE names(id int,first_name varchar(45),last_name varchar(45));
$qry=<<<QUERY
INSERT INTO
names(id,first_name,last_name)
VALUES
(1,"Thomas","Shelby"),
(2,"Joe","McMillan"),
(3,"Bruce","Robertson")
QUERY;
// That's it ...You inserted multiple records at once
$mysqli->query($qry);
// Let's check
$qry="SELECT * FROM names";
$result = $mysqli->query($qry);
while ($row = $result->fetch_assoc()) {
print_r($row);
}
?>
ALTERNATE TITLES