Insert Multiple Query we can do followings ways.

$conn->multi_query

This is useful .

<?php
$servername = “localhost”;
$username = “root”;
$password = “”;
$db = “test_exam”;

$conn = mysqli_connect($servername, $username,$password,$db);

// Check connection
if ($conn->connect_error) {
die(“Connection failed: ” . $conn->connect_error);
}
//echo “Connected successfully”;
$sql_insert = “INSERT INTO `student` (`fname`, `lname`) VALUES (‘test1’, ‘one’);”;
$sql_insert .= “INSERT INTO `student` (`fname`, `lname`) VALUES (‘test2’, ‘two’);”;
$sql_insert .= “INSERT INTO `student` (`fname`, `lname`) VALUES (‘test3’, ‘three’);”;

if($conn->multi_query($sql_insert)=== TRUE)
{
echo mysqli_insert_id($conn).”Record Inserted”;
}else
{
echo $conn->error();
}

?>