I'm sorry to keep posting this problem, but I'm using a cgi to search through a text database for records that have one particular field filled in (specifically, for vendors that are offering discounts/special deals. When I run the cgi, I have it set to search the particular field the discounts - all vendors with dicounts have something in the field, those who dont have discounts, have a blank field. However, when I output the results, it gives me every freaking entry in the database - please help - code for the search_record subroutine is below - thanks so much!
Ethan Altaratz
#build the search line with all fields we want to search in
$searchline = $discount;
#search by keywords
# only perform the keyword search if the length of the search string is greater than 2
# don't think we want people to search for and or or etc.
$sfound = 0;
$found = 0;
$notfound = 1;
$stlen = length($searchstring);
if ($stlen > 1) {
@words = split(/ +/,$searchstring);
foreach $aword (@words) {
if ($searchline =~ /\b$aword/i) {
$sfound = 1;
}
else {
$notfound = 0;
}
}
}
if ($sfound == 1 && $notfound == 1) {
$found = 1;
}
# if search string is too small .. set found to 1
if ($stlen <= 1) {
$found = 1;
}
#if page doesn't have a title then return not found
$tlen = length($linktitle);
if ($tlen < 1) {
$found = 0;
}
}
#####And here is the output html/javascript I'm using the results for:
print "message[$msg]=\"$discount|Girl band All Saints were knocked off the top spot in the British charts on Sunday.|print "\n";
$msg ++;
--so the only entries into this array should be the vendors with discounts listed, but it keeps giving me every entry
:-(
Ethan Altaratz
#build the search line with all fields we want to search in
$searchline = $discount;
#search by keywords
# only perform the keyword search if the length of the search string is greater than 2
# don't think we want people to search for and or or etc.
$sfound = 0;
$found = 0;
$notfound = 1;
$stlen = length($searchstring);
if ($stlen > 1) {
@words = split(/ +/,$searchstring);
foreach $aword (@words) {
if ($searchline =~ /\b$aword/i) {
$sfound = 1;
}
else {
$notfound = 0;
}
}
}
if ($sfound == 1 && $notfound == 1) {
$found = 1;
}
# if search string is too small .. set found to 1
if ($stlen <= 1) {
$found = 1;
}
#if page doesn't have a title then return not found
$tlen = length($linktitle);
if ($tlen < 1) {
$found = 0;
}
}
#####And here is the output html/javascript I'm using the results for:
print "message[$msg]=\"$discount|Girl band All Saints were knocked off the top spot in the British charts on Sunday.|print "\n";
$msg ++;
--so the only entries into this array should be the vendors with discounts listed, but it keeps giving me every entry
:-(