Gossamer Forum
Home : Products : DBMan : Customization :

Search problem

Quote Reply
Search problem
I have a penpal page, and have run into a problem. Someone adding a record has to specify if they are male or female. Then when a person searches for "male" the search will find "female" entries because the word male is found in female.

How can i work around this? Is there a way to force that field only to be case sensitive when searching or is there another way?
Eoin
Quote Reply
Re: Search problem In reply to
Yes, there is a way to force it to be case sensitive. You can add a hidden field to your form --

<input type="hidden" name="cs" value="1">

The other way is to change your database to choices between "M" and "F" instead of "Male" and "Female."


------------------
JPD





Quote Reply
Re: Search problem In reply to
How can I use
<input type="hidden" name="cs" value="1">
to force case sensitive on only one field (the Male or Female radio button)?
Quote Reply
Re: Search problem In reply to
I don't know of a way to do that, I'm afraid.

You could also try setting the "Whole words" flag. That might give your users more flexibility and will also keep "female" from being returned when the search is for "male."

<input type="hidden" name="ww" value="1">



------------------
JPD





Quote Reply
Re: Search problem In reply to
I am not sure of the value of front of word truncation (male gets female)I am sure it can be "turned off".

[This message has been edited by jury (edited August 24, 1999).]
Quote Reply
Re: Search problem In reply to
Thanks, but i don't get it. Which line in db.cgi will i change to the code you gave me?
Quote Reply
Re: Search problem In reply to
Are you talking to me, eoin, or jury?

If it's me, add the

<input type="hidden" name="ww" value="1">

to html.pl, sub html_view_search and sub html_view_failure, just below

<input type=hidden name="uid" value="$db_uid">



------------------
JPD





Quote Reply
Re: Search problem In reply to
I just remembered that what I did was to change the Whole Word search so that it did end of word truncation and then by always using whole word searches I achieved the result that male wouldn't get female but would get males. I am ashamed to say its a bit of a hack because I couldn't work out how to get this result on a regular search... but it works for me. Perhaps someone can work out how to add a word boundary at the front of a regular search.
Quote Reply
Re: Search problem In reply to
Sorry if I am getting everyone confused (I usually only do that to myself).
Quote Reply
Re: Search problem In reply to
OK, i think we're all a little confused now.

Whole word search sounds ok. BUT if there is, let's say, a comma after a word in an entry will the database find the whole word without the comma?

(i.e. I search for "skating" and there is an entry containing "skating, swimming")
Quote Reply
Re: Search problem In reply to
I don't know if it will or not. I haven't tried it.

Another thing you could try is adding some code to db.cgi, sub query.

After

local (sortby);

add

Code:
if ($in{'Gender'} eq "Male") {
$in{'Gender'} = '^Male';
$in{'re'} = 1;
}

You would have to change Gender to match your fieldname.

If someone searches for "Male," this creates a regular expression which requires the field to start with "Male" and sets the regular expression flag. Otherwise, it doesn't do anything. That way you could keep your case-sensitivity and be able to search for partial words.

There's lots of ways to accomplish most things. We just have to see which one fits best with your needs.


------------------
JPD





Quote Reply
Re: Search problem In reply to
Cool, that seems like the script i need. But right now i'm a bit sleepy at 1.30am. I'll try tomorrow Smile