Gossamer Forum
Home : Products : DBMan : Customization :

Creating a select list from previously returned results

Quote Reply
Creating a select list from previously returned results
I'm trying to create a way to narrow search results for my users. I display search results in a tabular format with a colmn header labeled for each field. I'd like a pick list to be in the top of each column beside the field name that contains ONLY items returned in the search.

As an example....
Database contains houses for sale. I do a seach for my zip code and 100 houses are returned and shown in columnar format. The database contains houses with 1 thru 5 bedrooms, but only 2 and 3 bedroom houses are in my zip code. I click the bedroom column pick list and it contains 2 bedroom and 3 bedroom... becuase that's all that is in my search result.

If I do a simple lookup fom database ( &build_select_field_from_db ), my pick list would contain 1 - 5 bedrooms because they are all in the database, but I only want my pick list to contain items from this search result.

I know the answer to this is in the array @hits, but how do I pass the values for a particular column in HITS to a sub that will build a select box for me? I'm just not very good with arrays... I'm sure the answer will be painfully obvious!

&html_record (&array_to_hash($_, @hits));


Take this snippet of code...
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]);
}
}
close DB;

Instead of opening DB, an I just pass HITS into this sub and omit the open and close statments, and simply say LINE: while (<HITS>) { ??????

Thanks....
Wes
Wes