Schells_Web_Design
asked on
Exact word searches excluding similar types of results
I have a Perl problem that's stumping me.
I have a small database that has a few fields.
There is a <select> menu that allows people to obtain results based on their selection.
The data in one of the fields would be something like:
Record 1: cat
Record 2: cat
Record 3: Black cat
Record 4: White cat
They want to be able to search for "cat" and ONLY bring back the results that only
have "cat" and no other ones....such as "Black cat" or "White cat." They want it exact word and that word or combination of words...only.
Is it possible? Any tricks? The Boolean tricks will not work for the <select> menu.
I'm hoping there is enough information for you to give an educated answer.
Thanks!
I have a small database that has a few fields.
There is a <select> menu that allows people to obtain results based on their selection.
The data in one of the fields would be something like:
Record 1: cat
Record 2: cat
Record 3: Black cat
Record 4: White cat
They want to be able to search for "cat" and ONLY bring back the results that only
have "cat" and no other ones....such as "Black cat" or "White cat." They want it exact word and that word or combination of words...only.
Is it possible? Any tricks? The Boolean tricks will not work for the <select> menu.
I'm hoping there is enough information for you to give an educated answer.
Thanks!
ASKER
So would I have to repeat this scenario you posted if there are 345 records? Would I have to write in all the possible options?
no, simplest would be to use a SQL statement like:
SELECT * FROM table WHERE your_field='cat';
> Would I have to write in all the possible options?
What do you mena by that? Could you please be more specific what you want to do, examples ..
SELECT * FROM table WHERE your_field='cat';
> Would I have to write in all the possible options?
What do you mena by that? Could you please be more specific what you want to do, examples ..
ASKER
Here's more what I mean...(I really appreciate the help)
I am using a flat-text file database, pipe-delimited.
There are 345 records.
Each record has 8 fields - one field is using a <select> drop-down to search for records in that category. It works perfect except when there are words that overlap in certain categories...such as 'cat', 'black cat', 'white cat' (as examples) - when someone searches for the drop down of 'cat' - it brings back ALL results with the word 'cat' in it. I think this is OK, and it makes sense to me, since the word 'cat' is in the field.
Searches using the 'black cat' drop down only result in the 'black cat' records, 'white cat' only 'white cat' records.
However, the person I am working with does not want 'black cat' brought back when they are only searching for 'cat'. They want to eliminate the 'black cat' and 'white cat' results.
There are 5 different words that overlap in this field. I just wanted to know if there was a relatively easy & quick method to search for the exact word and not include other words with the exact word I am searching for.
Does that help?
I'm not sure if it is possible using this set-up, and that's OK. I can always go to another set-up, but it would be useful if we could already use this as programmed.
Again, I appreaciate your help.
I am using a flat-text file database, pipe-delimited.
There are 345 records.
Each record has 8 fields - one field is using a <select> drop-down to search for records in that category. It works perfect except when there are words that overlap in certain categories...such as 'cat', 'black cat', 'white cat' (as examples) - when someone searches for the drop down of 'cat' - it brings back ALL results with the word 'cat' in it. I think this is OK, and it makes sense to me, since the word 'cat' is in the field.
Searches using the 'black cat' drop down only result in the 'black cat' records, 'white cat' only 'white cat' records.
However, the person I am working with does not want 'black cat' brought back when they are only searching for 'cat'. They want to eliminate the 'black cat' and 'white cat' results.
There are 5 different words that overlap in this field. I just wanted to know if there was a relatively easy & quick method to search for the exact word and not include other words with the exact word I am searching for.
Does that help?
I'm not sure if it is possible using this set-up, and that's OK. I can always go to another set-up, but it would be useful if we could already use this as programmed.
Again, I appreaciate your help.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks
$field_of_record3='Black cat';
print 'match' if ($field_of_record1=~m/^cat
print 'match' if ($field_of_record3=~m/^cat