Okay. I think this should work. (How many times have I said that and been wrong! LOL!!)
In html.pl, sub html_search options, after
Code:
INPUT TYPE="TEXT" NAME="keyword" SIZE=15 MAXLENGTH=255> Keyword Search <FONT SIZE=-1> (will match against all fields)</FONT><BR>
add
Code:
<INPUT TYPE="CHECKBOX" NAME="and"> Match separate words<BR>
(You can probably come up with some better wording for this.)
In db.cgi, sub query, after
Code:
if ($in{'keyword'}) { # If this is a keyword search, we are searching the same
$i = 0; # thing in all fields. Make sure "match any" option is
$in{'ma'} = "on"; # on, otherwise this will almost always fail.
add
Code:
# **************************************************************
if ($in{'and'}) {
@terms = split (/ /, $in{'keyword'});
$in{'keyword'} = '(' . $terms[0] . '.*' . $terms[1] . ')|(' . $terms[1] . '.*' . $terms[0] . ')';
$in{'re'} = "on";
}
# **************************************************************
(You don't really have to put the #*********** lines in, but it will make things easier to find as we work on this.)
At this point, you should be able to search for two words in any order. They have to be in the "keyword" field. If you put more than two words in the field, anything after the second one will be ignored.
I'm pretty sure I can code for searches using phrases. That shouldn't be too hard. I can probably set it up to work on individual fields, rather than just the keyword, but that'll take more work. I don't think I'm going to be able to do more than two search terms, though.
JPD
----------------------------------------------------
JPDeni's DBMan-ual How to
ask questions the smart way.