query("UPDATE customers SET name='John Smith' WHERE id=1"); /* Get the number of affected rows */ $num_rows = $mysqli->affected_rows; echo "Number of rows updated: " . $num_rows; ?>
prepare("INSERT INTO customers (name, email, phone) VALUES (?, ?, ?)"); /* Bind parameters */ $stmt->bind_param("sss", $name, $email, $phone); /* Insert multiple records */ $name = "John Smith"; $email = "john.smith@example.com"; $phone = "555-555-5555"; $stmt->execute(); $name = "Jane Doe"; $email = "jane.doe@example.com"; $phone = "555-555-5556"; $stmt->execute(); /* Get the number of affected rows */ $num_rows = $mysqli->affected_rows; echo "Number of rows inserted: " . $num_rows; ?>Package library: mysqli.