Answer the question
In order to leave comments, you need to log in
Why does the LIKE operator select only one word from a whole sentence?
There was a problem with the site search. When I enter one word into the search string, it displays all the records that have such a word, and when I enter two words or more, it displays nothing, nothing at all.
What is the problem?
The code:
if(isset($_POST['submit'])){
if($_POST['search']){
$word = $_POST['search'];
$name = "%$word%";
$sql_2 = "SELECT * FROM video WHERE title LIKE ? ORDER BY id DESC";
$stm = $pdo->prepare($sql_2);
$stm->execute(array($name));
$stm->fetch(PDO::FETCH_ASSOC);
}
}
Answer the question
In order to leave comments, you need to log in
You probably need a Full-Text search
Either break by words and do
WHERE title LIKE :word_1 AND title LIKE :word_2 etc.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question