How could this algorithm be improved to return better results for entire phrases?
```php
$terms = explode(" ", trim($query));
$conditions = [];
foreach ($terms as $term) {
$term = trim($term);
if ($term !== "") {
$term = sanitizeString($term);
$conditions[] = "title LIKE '%$term%'";
}
}
$where = count($conditions) > 0 ? implode(" OR ", $conditions) : "1";
$new = queryMysql("SELECT * FROM post
WHERE $where
ORDER BY id DESC
LIMIT $result_for_pages OFFSET $offset");
```
The issue is that the code snippet has not been very accurate in searching for words within a given sentence, thus causing certain searches to be skipped.