0
My question is relatively simple, but I couldn’t find an answer that would really help me:
My user searches for a name in a form: Fulano Silva
The record in my bank is like So-and-so of Tal Silva
SELECT * FROM `dados` WHERE `nome` LIKE '%".Fulano Silva."%'
When performing the search with PHP in Mysql by Fulano Silva using LIKE he will not be able to find the record!
If he had sought only by John Doe or by only by Silva, he would, but because there are more strings between Fulano and Silva (de Tal) the record is not found.
How can I resolve this situation? Should I separate the strings in the sentence and search them individually? How could I do that? Thank you!
... which can be done through
str_replace()
:str_replace(' ', '%', $texto);
– Marllon Nasser
Downvoter, can comment?
– Artur Trapp
Why the negative vote?
– Reginaldo Rigo
I don’t know either, I’m waiting for an explanation :/
– Artur Trapp
@Arturtrapp worked perfectly, that’s what I needed.
– NickoDog