For example, we have added a users table with three columns id, name, age with the following definition:
CREATE TABLE Users (id INTEGER AUTO_INCREMENT PRIMARY KEY, name VARCHAR(30), age INTEGER)
The INSERT command is used to add data to MySQL
//connect to database $conn = new mysqli("localhost", "root", "mypassword", "testdb"); //check an errors if($conn->connect_error){ die("error: " . $conn->connect_error);//return errors } //write the data in the varriable $sql $sql = "INSERT INTO Users (name, age) VALUES ('Sam', 41), ('Bob', 29), ('Alice', 32) "; //write users to the database and display errors if($conn->query($sql)){ echo "Users added"; } else{ echo "Error: " . $conn->error; } $conn->close();