Hi Max,
I would like to create a form in which an admin initially searches for a Joomla user by entering a part of the name in a search field, and afterwards they will do some modifications on this record.
So on the first page I created a text field in which they will enter a part of the name of the user they are looking for. I don't want them to have to enter the full name as it is prone to spelling mistakes and it takes a lot of time. On the next page an SQL query is executed with this text value as parameter in the WHERE clause and it shows the result in a table.
In order to give the user the freedom to enter a part of the name I use the LIKE operator with the % sign.However, the SQL query never returns any records. When I simply don't use the LIKE operator but just the = operator, it works correctly (but I have to enter the full name) in the search field. The SQL query (with the LIKE operator) also works fine when I execute it as a test in the database directly.
Am I forgetting something?
Please see the attached images.
Best regards,
Bart
Hi Max,
Actually I already found a workaround 😅
I added the % signs by adding a variable, and used this variable in the SQL query.
Best regards,
Bart
correct, but you should modify the SQL query to be like this:
LIKE {var.quote:zoeknaam_wildcard}
this is in order to prevent SQL injection, the variable value will be safely quoted by mysql