Need help excluding certain terms from database search.
Hi folks -thanks for any input.
I'm running a MySQL database client version: 3.23.58
The database contains a lot of comic strips and is designed to be searchable by keyword (among other things). Each strip's record contains keywords related to its content, and it also includes a list of every character who appears in that strip.
However, I want to restrict people from searching for specific keywords, for example "George", because searching for the word George would bring up nearly all of the strips in the database, as George is in almost all of them - something we're hoping to avoid. With thousands of records, it wouldn't make sense for me to remove all instances of George from the keywords field, either.
Here's the way my query is presently structured. I capture the keywords from an input form, trim the whitespace and then run the query.
This works well to let people search for the terms we want to allow, like "flower", "flowers", "flowering", but I want to refuse to let people enter "George", "Georg", "orge" etc. and having every George-related strip show up.
$query = "select * from table where description like \"%$trimmed%\" order by date";
I started experimenting with if statements to deny the search based on the value of %$trimmed%, but as you can see this gets problematic quickly especially for characters with longer names. There's got to be a better method.
Any ideas? Thanks so much.
$trimmed == "George" or
$trimmed == "george" or
$trimmed == "eorge" or
$trimmed == "orge"
echo "<p>Generate message denying the search</p>";