How can multiple SQL statements be executed in PHP using the query() function?
When using the query() function in PHP to execute multiple SQL statements, you can separate the statements with a semicolon. This allows you to execute multiple queries in a single call to the query() function. However, be cautious when executing multiple statements as it can pose security risks such as SQL injection.
// Example of executing multiple SQL statements using the query() function
$query = "SELECT * FROM table1; SELECT * FROM table2;";
$result = $conn->query($query);
if ($result) {
// Process the results of the queries
} else {
echo "Error executing query: " . $conn->error;
}