% value %
This is a conditional expression using LIKE that allows to retrieve partially matched records.
I am currently writing the basic processing of the search function that retrieves data from MySQL using PHP.
It's going well until I get the search results, but the display is strange
For example, if you put t1 in the search form and there is a record called test1, you will get a record called test1
The reason is that somehow I noticed that the front and back matches (%) and the back matches (%), so the letters at the beginning and the end match.
I thought...what do you think?
Here's a part of the code.
$stmt=$pdo->prepare("select*from search where word LIKE:word");
$stmt->execute([(':word'=>"%$word%");
$word
contains the values entered in $_POST
What I want to achieve is
Do not retrieve matching records just because you enter the first and last characters.
Match only the characters that follow
Yes, please help me
php mysql
%
matches an empty string, so %t1%
matches test1.
© 2024 OneMinuteCode. All rights reserved.