Well, these codes may work.
Since you have two links databases, I am sure that you also have two different .cfg files (or different variables in one .cfg file) and that you have two links.def files.
If you have two different .cfg files, then you will have to require both .cfg files in the
Required Libraries section of the
search.cgi file.
Make sure that you have unique variable names for the databases, like
$db_file_name and
$db_file2_name.
Then follow these steps:
1) Add the following codes:
Code:
if ($in{'dbtype'} eq "database1") {
before the following codes:
Code:
open (DB, "<$db_file_name")...
2) Then add a closing right bracket after the following codes:
3) Then add the following codes after the closing right bracket you added:
Code:
if {$in{'dbtype'} eq "database2") {
# Go through second database.
open (DB2, "<$db_file2_name") or &cgierr("error in search. unable to open database: $db_file_name. Reason: $!");
flock (DB2, 1) if ($db_use_flock);
LINE: while (<DB> ) {
/^#/ and next LINE; # Skip comment Lines.
/^\s*$/ and next LINE; # Skip blank lines.
chomp; # Remove trailing new line.
@values = &split_decode($_);
$grand_total++;
# Check to see if the link matches.
$match = 0; $andmatch = 1;
if ($regexp) {
FIELD: foreach $field (@search_fields) {
$_ = $values[$field];
$or_match ?
($match = $match | | &{$regexp}) :
($match = &{$regexp});
last FIELD if ($match);
}
}
# Check to see if the link matches any database fields. Only exact matches
# here.
if ($or_match | | $match | | !$regexp) {
FIELD: foreach $field (@field_search) {
if ($or_match) {
$match = $match | | ($in{$db_cols[$field]} eq $values[$field]);
$match and last FIELD;
}
else {
$match = ($in{$db_cols[$field]} eq $values[$field]);
$match or last FIELD;
}
}
}
$andmatch = $andmatch && $match;
# If we have a hit, add it in!
if (($or_match && $match) or $andmatch) {
push (@{$link_results{$values[$db_category]}}, @values);
$numhits++; # We have a match!
}
# Check to see if the category matches.
if ($regexp and !$seen{$values[$db_category]}++) {
$match=0; $andmatch = 1;
$_ = $values[$db_category];
$or_match ?
($match = $match | | &{$regexp}) :
($match = &{$regexp});
$andmatch = $andmatch && $match;
if (($or_match && $match) or $andmatch) {
$numcat++;
push (@category_results, $values[$db_category]);
}
}
}
close DB2;
}
4) Then in your
search.html template file or anywhere else you have your search form codes, add the following codes:
Code:
<input type="radio" name="dbtype" value="database1"> Database1
<input type="radio" name="dbtype" value="database2"> Database2
These are pretty intensive codes and may not work very well. But this is a quick and dirty solution to your inquiry.
Hope this works and helps.
Regards,
------------------
Eliot Lee Anthro TECH,L.L.C
www.anthrotech.com ----------------------
[This message has been edited by Eliot (edited December 09, 1999).]