How do I insert data into a table

In MySQL, you can insert data into a table using the `INSERT INTO` statement. Below is an example that shows how to add a new record to a table named `employees`.

<?php $servername = "localhost"; $username = "username"; $password = "password"; $dbname = "database_name"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } // SQL to insert data $sql = "INSERT INTO employees (firstname, lastname, email) VALUES ('John', 'Doe', 'john.doe@example.com')"; if ($conn->query($sql) === TRUE) { echo "New record created successfully"; } else { echo "Error: " . $sql . "<br>" . $conn->error; } $conn->close(); ?>

MySQL INSERT INTO database SQL PHP