I have a sql database that contains 2,000 records and within it, I have a field called `fullname`
I then have a php website form which has a field called personsname`, the form method is "GET"
At the moment im performing a standard query which looks like
$sql = "SELECT * FROM peoplesnames WHERE fullname LIKE '%".$_GET['personsname']."%'";
So if there is a record in the field called "DavidLawson" then this is returned if the user searches for "David" or "Lawson" or "vidLaws" and so on.
What I want to do is to keep the same query but change it so that it replaces the letter A with a K in the field data when it does the search.
Keeping the "DavidLawson" example above, if I then did a search for "David", it would return nothing, but if I did a search for "Dkvid" it would return a result as it has replaced the "a" in "David" with a "k", again, if I did a search for "DkvidLawson" it would find nothing as "Lawson" contained a "a", but if I did a search for "DkvidLkwson" then it would return a result.
Does that make sense?
I have been battling with this for ages,
I have tried to change it to
$sql = "SELECT * FROM peoplesnames WHERE fullname LIKE '%".str_replace("a", "k", $_GET['personsname'])."%'";
but that didnt seem to work.
Can anyone help?
Thanks a million in advance