Created
December 27, 2020 21:39
-
-
Save barmgeat/8470eb525781ca0d9c219619630e2d7e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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); | |
} | |
//create string statement . | |
$sql = "INSERT INTO MyGuests (firstname, lastname, email) | |
VALUES ('John', 'Doe', '[email protected]');"; | |
//here we concatent the data to insert to the database : | |
$sql .= "INSERT INTO MyGuests (firstname, lastname, email) | |
VALUES ('Mary', 'Moe', '[email protected]');"; | |
//here we concatent the data to insert to the database : | |
$sql .= "INSERT INTO MyGuests (firstname, lastname, email) | |
VALUES ('Julie', 'Dooley', '[email protected]')"; | |
//then we use multi_query function to insert the data to the Table MyGuestes | |
if ($conn->multi_query($sql) === TRUE) { | |
echo "New records created successfully"; | |
} else { | |
echo "Error: " . $sql . "<br>" . $conn->error; | |
} | |
$conn->close(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment