How can you perform a SQL query with multiple conditions in PHP?

When performing a SQL query with multiple conditions in PHP, you can use the "AND" or "OR" operators to combine different conditions in the WHERE clause of the SQL query. This allows you to filter the results based on multiple criteria. Additionally, you can use placeholders and bind parameters to prevent SQL injection attacks.

<?php
// Establish a database connection
$pdo = new PDO('mysql:host=localhost;dbname=mydatabase', 'username', 'password');

// Prepare the SQL query with multiple conditions
$stmt = $pdo->prepare("SELECT * FROM my_table WHERE condition1 = :value1 AND condition2 = :value2");

// Bind the parameter values
$value1 = 'some_value';
$value2 = 'another_value';
$stmt->bindParam(':value1', $value1);
$stmt->bindParam(':value2', $value2);

// Execute the query
$stmt->execute();

// Fetch the results
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);

// Output the results
print_r($results);
?>