mscsearch2
戻る
#!C:/perl/bin/perl
######################################
# mscsearch2.pl
######################################
use strict;
use DBI;
use CGI qw/:standard/;
use HTML::Template;
my ( %t,@rec,@loop );
$t{q} = new CGI;
$t{enq1_id} = $t{q}->param("enq1_id");
$t{main_type1id} = $t{q}->param("SEL1");
$t{template} = HTML::Template->new(filename => 'mscsearch2.htm');
$t{dsn} = "DBI:mysql:host=localhost;database=cookbook";
$t{dbh} = DBI->connect($t{dsn}, "cbuser", "cbpass") or die "Cannot connect to server\n";
$t{dbh}->do("SET NAMES utf8");
if(!$t{dbh}){
print "SQL read ERROR!\n";
exit;
}
$t{sth} = $t{dbh}->prepare("select * from parts1 where engine = $t{main_type1id}");
$t{sth}->execute;
@loop = ();
while (@rec = $t{sth}->fetchrow_array) {
my %row = (
id2 => $rec[0],
name => $rec[1]
);
# put this row into the loop by reference
push(@loop, \%row);
}
$t{sth}->finish;
$t{dbh}->disconnect;
$t{template}->param(THIS_LOOP => \@loop);
$t{template}->param(enq1_id => $t{enq1_id});
$t{template}->param(main_type1id => $t{main_type1id});
# send the obligatory Content-Type and print the template output
print $t{template}->output;
1;
-------------------------------------------------------------------------------
mscsearch2
mscsearch2
http://localhost/scripts/mscenq1_p.pl
ENQ_ID==>
main_type1id==>
戻る