How can the PHP search function be optimized to ensure accurate results?

To optimize the PHP search function for accurate results, we can use the MySQL "LIKE" operator to perform a case-insensitive search on the database. By using this operator, we can ensure that the search results are not affected by the case sensitivity of the input query.

$search_query = $_GET['search_query'];
$sql = "SELECT * FROM table_name WHERE column_name LIKE :search_query";
$stmt = $pdo->prepare($sql);
$stmt->execute(['search_query' => '%' . $search_query . '%']);
$results = $stmt->fetchAll();