#!/perl/bin/perl use strict; use CGI; use CGI::Carp qw(fatalsToBrowser warningsToBrowser ); # setup CGI handle my $cgi = new CGI; # Number of form fields that have arrived here my $num = $cgi->param(); # The variables my @vars = $cgi->param(); # define x for strict my $x; # start HTML print $cgi->header . $cgi->start_html('Drive'); # This is one way [ not super duper, or safe from bad form input ] , just a simple example ! of building the SQL Query # ---------------------------------------------------------------------------------------------------- # Plain text my $sql = "SELECT ResType, ResLevel, ResManage, Details, Length, Source, Cost, FurtherDetails FROM ResourceSettings, Resources WHERE "; for ($x=0; $x < $num-1; $x++) { $sql .= " " . $vars[$x] ." =\"" . $cgi->param($vars[$x]) ."\" "; if ($x < $num-2) { $sql .= " AND "; } } $sql .=" ORDER BY ResType, ResLevel, ResManage,Details, Length, Source, Cost, FurtherDetails"; # ---------------------------------------------------------------------------------------------------- # color added for fun my $sql2 = "SELECT ResType, ResLevel, ResManage, Details, Length, Source, Cost, FurtherDetails FROM ResourceSettings, Resources WHERE "; for ($x=0; $x < $num-1; $x++) { $sql2 .= " " . $vars[$x] ." =\"" . $cgi->param($vars[$x]) ."\" "; # Only add an AND if it is required if ($x < $num-2) { $sql2 .= " AND "; } } $sql2 .=" ORDER BY ResType, ResLevel, ResManage,Details, Length, Source, Cost, FurtherDetails"; print $cgi->p($sql); print $cgi->p($sql2); # IF you use checkboxes with the same name on the form # You can collect all the values with cgi.pm as such....... my @drive = $cgi->param('drive'); print $cgi->h3('Values for " same named drive " checkboxes'); foreach my $drive(@drive) { print "$drive
\n"; }