I’m working on a place where you can search a user by their full name. The problem i’ve run into is right now it’s two separate fields for first and last name. I’m trying to do a search where if someone types “Jon Smith” it looks for the people with the name “Jon Smith”. I know I could explode the variable given and search with the exploded variable, but that has some flaws too. But I wanted to know if there is any other way to fix this other than exploding a variable or setting up another field.
Share
You could use a full-text index to use a full text search directly in your database. This way it would be irrelevant if someone types those values in another order. Also this can give you a score value if someone types in a username which does not exactly match your query if that is what you desire.