Search
 
SCRIPT & CODE EXAMPLE
 

PHP

PHP MySQL Insert Multiple Records

<?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 ('John', 'Doe', 'john@example.com');";
$sql .= "INSERT INTO MyGuests (firstname, lastname, email)
VALUES ('Mary', 'Moe', 'mary@example.com');";
$sql .= "INSERT INTO MyGuests (firstname, lastname, email)
VALUES ('Julie', 'Dooley', 'julie@example.com')";

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

$conn->close();
?>
Comment

PREVIOUS NEXT
Code Example
Php :: php flip array 
Php :: woocommerce update_status 
Php :: php integer 
Php :: publish spatie 
Php :: laravel collection to json 
Php :: php run command terminal 
Php :: random string number generator in php codeigniter 
Php :: Creating (Declaring) PHP Variables 
Php :: php while loop 
Php :: Redirect action to certain controller method in Laravel 
Php :: preg_split in php 
Php :: php include multiple files at once 
Php :: php globals 
Php :: laravel eloquent get all where in 
Php :: Corsair K70 RGB MK.2 
Php :: in array php 
Php :: php check jwt token expired 
Php :: php input radio 
Php :: Laravel - Add conditional where clause in query 
Php :: spatie activity log 
Php :: return back laravel controller 
Php :: php str starts with 
Php :: laravel creat new model 
Php :: laravel how to nested foreach 
Php :: how to add javascript to a php variable 
Php :: git reset head 3 . how to back git init 
Php :: laravel https middleware 
Php :: laravel move/rename file ftp 
Php :: php print string as bytes 
Php :: Add button next to "ADD TO CART" on product archive 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =