Recall & Review
beginner
What is the purpose of the INSERT operation in PHP with databases?
The INSERT operation adds new records (rows) into a database table.
Click to reveal answer
beginner
How do you update a record in a database using PHP?
You use the UPDATE SQL statement with PHP to change existing data in a table, usually specifying which record to update with a WHERE clause.
Click to reveal answer
beginner
What does the DELETE operation do in PHP database handling?
DELETE removes one or more records from a database table based on a condition.
Click to reveal answer
intermediate
Show a simple PHP code snippet to insert a new user with name and email into a MySQL database.
$name = 'Alice';
$email = 'alice@example.com';
$sql = "INSERT INTO users (name, email) VALUES ('$name', '$email')";
mysqli_query($conn, $sql);
Click to reveal answer
beginner
Why is it important to use a WHERE clause in UPDATE and DELETE operations?
Without a WHERE clause, UPDATE or DELETE will affect all rows in the table, which can cause data loss or unwanted changes.
Click to reveal answer
Which SQL statement is used to add new data to a table?
✗ Incorrect
INSERT adds new rows to a table.
What happens if you run an UPDATE statement without a WHERE clause?
✗ Incorrect
Without WHERE, UPDATE affects every row.
Which PHP function is commonly used to execute SQL queries?
✗ Incorrect
mysqli_query() runs SQL commands in PHP.
What does the DELETE statement do?
✗ Incorrect
DELETE removes records from a table.
Which clause specifies which rows to update or delete?
✗ Incorrect
WHERE filters rows for UPDATE or DELETE.
Explain how to safely insert, update, and delete records in a database using PHP.
Think about the SQL commands and how PHP runs them.
You got /5 concepts.
Describe the risks of running UPDATE or DELETE operations without a WHERE clause in PHP database code.
What happens if you forget to specify which rows to change?
You got /4 concepts.