Code has been added to clipboard!

Multiple MySQL Rows for MySQLi Object-Oriented

Example
<?php
  $host = 'host';
  $user = 'user';
  $pass = 'pass';
  $db = 'db';
  // Create connection
  $conn = new mysqli($host, $user, $pass, $dbname);
  // Check connection
  if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
  }
  $sql = "INSERT INTO users (username, password, email) VALUES ('Johny', 'Dawkins', '[email protected]');";
  $sql .= "INSERT INTO users (username, password, email) VALUES ('Margaret', 'Johnson', '[email protected]');";
  $sql .= "INSERT INTO users (username, password, email) VALUES ('Juliete', 'Doodley', '[email protected]');";
  if ($conn->multi_query($sql) === TRUE) {
    echo "New records created successfully";
  } else { 
    echo "Error: " . $sql . "<br>" . $conn->error;
  }
  $conn->close();  
?>