Gossamer Forum
Home : Products : DBMan SQL : Discussion :

Re: [jiliu] searching for multiple words

Quote Reply
Re: [jiliu] searching for multiple words In reply to
Hi,

Alright, just make a little change:

....
my $db = $home->{cgi}->{db};
my $table = $DB->table($db);
$table->select_options("Order by $column",$limit);
my $cond = GT::SQL::Condition->new ();
if ($home->{cgi}->{mul}) { #search words
my $words = [split /\s/,$letter];
$cond->{bool} = 'OR';
foreach (@$words) {
($_) and $cond->add($column,'LIKE',"%$_%");
}
}
else { # search starting with a letter
$cond->add($column,'LIKE',"$letter%");
}
my $sth = $table->select ($cond);
my $hits = $table->hits();
....

It should work for both, if you wanna search words then pass mul=1 or add <input name=mul value=1 type=hidden> in your search form.

Cheers,

TheStone.


B.

Last edited by:

TheStone: Jan 18, 2002, 10:53 AM
Subject Author Views Date
Thread searching for multiple words jiliu 6685 Jan 18, 2002, 5:28 AM
Thread Re: [jiliu] searching for multiple words
604 6564 Jan 18, 2002, 9:57 AM
Thread Re: [TheStone] searching for multiple words
jiliu 6559 Jan 18, 2002, 10:08 AM
Thread Re: [jiliu] searching for multiple words
604 6575 Jan 18, 2002, 10:24 AM
Thread Re: [TheStone] searching for multiple words
jiliu 6576 Jan 18, 2002, 10:33 AM
Thread Re: [jiliu] searching for multiple words
604 6569 Jan 18, 2002, 10:48 AM
Post Re: [TheStone] searching for multiple words
jiliu 6518 Jan 18, 2002, 11:12 AM
Thread Re: [TheStone] searching for multiple words
Reena0330 6389 Aug 7, 2002, 3:25 PM
Thread Re: [Reena0330] searching for multiple words
604 6422 Aug 7, 2002, 3:41 PM
Thread Re: [TheStone] searching for multiple words
jai 6157 Feb 10, 2003, 9:22 PM
Post Re: [jai] searching for multiple words
604 6179 Feb 11, 2003, 10:34 AM
Post Re: [jai] searching for multiple words
604 6069 Feb 28, 2003, 4:32 PM