Hi,
Well, I didn't have much response to my previous posts; I guess I'm not explaining myself right, sorry...
Meanwhile, I found something that does what I want, from the Unofficial Help/FAQ:
sub list_titles {
#----------------------------------
my ($cat_field,$cat_name,%titles,$title,@fields);
my $fieldnum1 = 4; # Change this to the number of your Category field
my $fieldnum2 = 5; # Change this to the number of your Title field
open (DB, "<$db_file_name") or &cgierr("error in list_titles. unable to open db file: $db_file_name.\nReason: $!");
if ($db_use_flock) { flock(DB, 1); }
LINE: while (<DB>) {
next if /^#/;
next if /^\s*$/;
$line = $_;
chomp ($line);
@fields = &split_decode ($line);
if ($fields[$fieldnum1] eq $in{$db_cols[$fieldnum1]}) {
$titles{$fields[$fieldnum2]} = $fields[$db_key_pos];
}
}
close DB;
$cat_field = &urlencode($db_cols[$fieldnum1]);
$cat_name = &urlencode($in{$db_cols[$fieldnum1]});
foreach $title (sort keys %titles) {
print qq|
<a href="$db_script_link_url&$cat_field=$cat_name&$db_key=$titles{$title}&ww=on&view_records=1">$title</a> |;
}
}
You can see how it works at:
http://www.plurinet.com/cgi-local/produto/index.cgi?db=default&uid=default&marca=Polaroid&ID=10&submarca=Kids&ww=on&view_records=1
(it's in Portuguese)
This does what I want, but I need to extend it further, so the subroutine checks a 3rd field...
I have the following fields:
1-Type
2-Brand
3-SubBrand
4- Model
my $fieldnum1 = 1; # Type
my $fieldnum2 = 2; # Brand
And this works halfway:
It lists all the models from BrandX & TypeX; I need to include the SubBrand field on this subroutine... is it possible?
I tried to add
my $fieldnum3 = 3; # subModel
, but I don't know what to do next for it to work...
Also, I need exclude the current record being displayed from the list that the above subroutine returns...
I'm sorry if I'm not being clear, but my Perl knowledge is very limited, and I'm pretty desperate, at this time...
Thank you for any help,
Gustavo Melo
Well, I didn't have much response to my previous posts; I guess I'm not explaining myself right, sorry...
Meanwhile, I found something that does what I want, from the Unofficial Help/FAQ:
sub list_titles {
#----------------------------------
my ($cat_field,$cat_name,%titles,$title,@fields);
my $fieldnum1 = 4; # Change this to the number of your Category field
my $fieldnum2 = 5; # Change this to the number of your Title field
open (DB, "<$db_file_name") or &cgierr("error in list_titles. unable to open db file: $db_file_name.\nReason: $!");
if ($db_use_flock) { flock(DB, 1); }
LINE: while (<DB>) {
next if /^#/;
next if /^\s*$/;
$line = $_;
chomp ($line);
@fields = &split_decode ($line);
if ($fields[$fieldnum1] eq $in{$db_cols[$fieldnum1]}) {
$titles{$fields[$fieldnum2]} = $fields[$db_key_pos];
}
}
close DB;
$cat_field = &urlencode($db_cols[$fieldnum1]);
$cat_name = &urlencode($in{$db_cols[$fieldnum1]});
foreach $title (sort keys %titles) {
print qq|
<a href="$db_script_link_url&$cat_field=$cat_name&$db_key=$titles{$title}&ww=on&view_records=1">$title</a> |;
}
}
You can see how it works at:
http://www.plurinet.com/cgi-local/produto/index.cgi?db=default&uid=default&marca=Polaroid&ID=10&submarca=Kids&ww=on&view_records=1
(it's in Portuguese)
This does what I want, but I need to extend it further, so the subroutine checks a 3rd field...
I have the following fields:
1-Type
2-Brand
3-SubBrand
4- Model
my $fieldnum1 = 1; # Type
my $fieldnum2 = 2; # Brand
And this works halfway:
It lists all the models from BrandX & TypeX; I need to include the SubBrand field on this subroutine... is it possible?
I tried to add
my $fieldnum3 = 3; # subModel
, but I don't know what to do next for it to work...
Also, I need exclude the current record being displayed from the list that the above subroutine returns...
I'm sorry if I'm not being clear, but my Perl knowledge is very limited, and I'm pretty desperate, at this time...
Thank you for any help,
Gustavo Melo