0
I looked for answers here in the community, but I couldn’t find anything specific. I have a page where I can search the name of previously registered clients in a Mysql database. Currently, I am using the following sentences:
PHP: $valor = str_replace(' ', '%', $pesquisa);
SQL: "select * from user where nome like '%".$valor."%' order by nome asc;"
Being that PHP variable $research, comes from a search form on the same page. (The above code allows me to do searches with more than one value). For example, if there is a client in the database called Luiz Henrique da Silva, and I search for Luiz, Luiz Henrique, or even Luiz Silva, this code will work perfectly, listing such a user.
However, if I search the name out of order, like Silva Henrique, or da Silva Luiz, the user will not be listed. How could this reverse search be possible in a simple way?
Hello friend. Thank you for commenting. But as I said in the description, the function str_replace helps me in this question, it replaces the space between the words in the search by a %, so if I search Luiz Silva it will be listed perfectly. My question is how to perform a reverse search. I want to search Silva Luiz, and have this user returned as well. Understand?
– Guilhermy