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 8428 Jan 18, 2002, 5:28 AM
Thread Re: [jiliu] searching for multiple words
604 8283 Jan 18, 2002, 9:57 AM
Thread Re: [TheStone] searching for multiple words
jiliu 8276 Jan 18, 2002, 10:08 AM
Thread Re: [jiliu] searching for multiple words
604 8290 Jan 18, 2002, 10:24 AM
Thread Re: [TheStone] searching for multiple words
jiliu 8295 Jan 18, 2002, 10:33 AM
Thread Re: [jiliu] searching for multiple words
604 8288 Jan 18, 2002, 10:48 AM
Post Re: [TheStone] searching for multiple words
jiliu 8234 Jan 18, 2002, 11:12 AM
Thread Re: [TheStone] searching for multiple words
Reena0330 8107 Aug 7, 2002, 3:25 PM
Thread Re: [Reena0330] searching for multiple words
604 8144 Aug 7, 2002, 3:41 PM
Thread Re: [TheStone] searching for multiple words
jai 7876 Feb 10, 2003, 9:22 PM
Post Re: [jai] searching for multiple words
604 7893 Feb 11, 2003, 10:34 AM
Post Re: [jai] searching for multiple words
604 7783 Feb 28, 2003, 4:32 PM