Gossamer Forum
Home : Products : DBMan : Customization :

search within a search

Quote Reply
search within a search
I don't know if this can be done with a non SQL version of DBMan, but I'll ask anyway.
What I would like to do is to add a hidden field, to a keyword search.
The hiden field value being $in{Country} is derived from previous dropdown list of countrys. No problem in doing this.
The problem is getting the country field to work with the keyword search.
The resulting search string will look like this, Country=Austraila&keyword=Boats&mh=10&so=ascend&view_records=Go
DBMan ignores the country field and just searches by keyword.
Anyway of getting this to work, so I can do keyword searches by selected country.

thanks
Bob
Quote Reply
Re: search within a search In reply to
You can alter the script so that it doesn't overwrite the Country field with the contents of the keyword field, which is what it seems you want to do. However, if you do, the search won't work.

The way the keyword search works is to fill all of the fields (except date fields and userid fields) with the keyword. It sets the "match any" flag. If it didn't, you wouldn't get any search results from the keyword search.

If you prevent the keyword from being written into the Country field, the results of the search will be all records with the matching Country value and all records with the keyword.

I don't know enough about all the inner workings of the search to be able to alter it to do what you want.


------------------
JPD





Quote Reply
Re: search within a search In reply to
Thanks JPD I thought that may have been the case.
If you do think of anything please let me know.

Thanks
Bob
Quote Reply
Re: search within a search In reply to
Ok if we carn't do it with a keyword search, can we modify your list categories mod you did awhile back (which I am using) to browse within a previously selected country.
Code:
sub html_list_categories {
# --------------------------------------------------------
for ($i = 0; $i <= $#db_cols; $i++) {
if ($db_cols[$i] eq "Category" ) {
$fieldnum = $i; $found = 1;
last;
}
}
if (!$found) {
&cgierror("No Category field defined");
}
if ($in{'Category'}) {
$page_title = "$in{'Category'} sub-category listing";
&html_page_top;
$found = 0;
for ($i = 0; $i <= $#db_cols; $i++) {
if ($db_cols[$i] eq "Subcategory" ) {
$fieldnum2 = $i; $found = 1;
last;
}
}
if (!$found) {
&cgierror("No Subcategory field defined");
}
open (DB, "<$db_file_name") or &cgierr("unable to open $db_file_name. Reason: $!");
if ($db_use_flock) { flock(DB, 1); }
LINE: while (<DB> ) {
next if /^#/;
next if /^\s*$/;
$line = $_;
chomp ($line);
@fields = &split_decode ($line);
if ($fields[$fieldnum] eq $in{'Category'}) {
if (!(grep $_ eq $fields[$fieldnum2], @selectfields)) {
push (@selectfields, $fields[$fieldnum2]);
}
}
++$count{$fields[$fieldnum2]};
}
close DB;
foreach $field (sort @selectfields) {
$sfield = &urlencode($field);
print qq|<$font><a href="$db_script_link_url&Category=$in{'Category'}&Subcategory=$sfield&view_records=1">$field</a> ($count{$field})</font>|;
}
}
else {
$page_title = "Category Listing";
&html_page_top;

open (DB, "<$db_file_name") or &cgierr("unable to open $db_file_name. Reason: $!");
if ($db_use_flock) { flock(DB, 1); }
LINE: while (<DB> ) {
next if /^#/;
next if /^\s*$/;
$line = $_;
chomp ($line);
@fields = &split_decode ($line);
if (!(grep $_ eq $fields[$fieldnum], @selectfields)) {
push (@selectfields, $fields[$fieldnum]);
}
++$count{$fields[$fieldnum]};
}
close DB;
foreach $field (sort @selectfields) {
$sfield = &urlencode($field);
}
print qq|<$font><a href="$db_script_link_url&list_categories=1&Category=$sfield">$field</a> ($count{$field})</font>|;
}
}
&html_footer;
&html_page_bottom;
}

The query string from the country dropdown reads - &Country=Australia&list_categories=go, so at the momemt it does a category list for all countrys.

thanks
Bob


[This message has been edited by lanerj (edited October 18, 1999).]
Quote Reply
Re: search within a search In reply to
That might work. It's been so long since I wrote that, though, we'd probably have to start over.

I'm not really sure what you want to do. Explain it to me like I was a three-year-old. Smile


------------------
JPD





Quote Reply
Re: search within a search In reply to
I,ve had a bit of practice at talking like a 3 year old recently, my grand daughter is about to have her first birthday, so here goes.
What I have is a drop down list of countries, derived from another database.
What I would like users to do a search from within the country they select, ie if they select Australia, and hit Go, it will display a list of categories(with totals) available for Australia or the country they select. Then they select a category, to return a list of sub categoties(with totals) for Australia. Selecting a sub category will display the available records, again by Australia.
Australia>Boats>Sail>search results, or USA>Boats>Sail>search results.
What I need to do with the list_categories is to first display a list of categories available by the country selected. I can then carry on the country search by using &Country=$in{'Country'}in the category and sub category url of the list_categories mod.
I hope you can understand this as I havn't had the chance to run it passed my grand daughter yet.

thanks
Bob
Quote Reply
Re: search within a search In reply to
 Smile )


------------------
JPD





Quote Reply
Re: search within a search In reply to
I know JPD has been away for awhile, I persume she is not feeling well.
Would anyone else like to have a go at this, or should I wait for JPD.

Thanks
Bob
Quote Reply
Re: search within a search In reply to
Just putting this back on top of the pile.
ANYONE?

thanks
Bob