Insert Multiple Records OO

New records created successfully

Here is the code for accessing the database and display the information.

<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
  die("Connection failed: " . $conn->connect_error);
}

$sql = "INSERT INTO MyGuests (firstname, lastname, email)
VALUES ('Donald', 'Duck', 'dduckn@example.com');";
$sql .= "INSERT INTO MyGuests (firstname, lastname, email)
VALUES ('Daisy', 'Duck', 'daisyduck@example.com');";
$sql .= "INSERT INTO MyGuests (firstname, lastname, email)
VALUES ('Julie', 'Dooley', 'juliedooley@example.com')";

if ($conn->multi_query($sql) === TRUE) {
  echo "New records created successfully";
} else {
  echo "Error: " . $sql . "
" . $conn->error
; } $conn->close(); ?>