What specific SQL statements and clauses should be used in PHP to search data in a database?

To search data in a database using PHP, you can use the SQL SELECT statement along with the WHERE clause to specify the search criteria. You can also use the LIKE operator for partial matches, and the ORDER BY clause to sort the results. Lastly, you can use prepared statements to prevent SQL injection attacks.

// Connect to the database
$pdo = new PDO('mysql:host=localhost;dbname=mydatabase', 'username', 'password');

// Search for specific data
$searchTerm = 'example';
$stmt = $pdo->prepare("SELECT * FROM mytable WHERE column_name LIKE :searchTerm");
$stmt->execute(['searchTerm' => "%$searchTerm%"]);

// Fetch and display the results
$results = $stmt->fetchAll();
foreach($results as $row) {
    echo $row['column_name'] . "<br>";
}