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; ------------------------------------------------------------------------------- <html> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <head><title>mscsearch2</title> <head> <body bgcolor="#fcf5ca"> <h2>mscsearch2</h2> <a href="http://localhost/scripts/mscenq1_p.pl">http://localhost/scripts/mscenq1_p.pl</a> <hr> ENQ_ID==><TMPL_VAR NAME="enq1_id"><br> main_type1id==><TMPL_VAR NAME="main_type1id"><br> <table> <tr bgcolor=white> <th>Radio</th> <th>name</th> </tr> <form method="POST" action="mscupdate2.pl"> <input type="submit" value="選択したデータを追加">==>http://localhost/scripts/mscupdate2.pl <input type="hidden" name="enq1_id" value="<TMPL_VAR NAME="enq1_id">"> <input type="hidden" name="main_type1id" value="<TMPL_VAR NAME="main_type1id">"> <TMPL_LOOP NAME="THIS_LOOP"> <tr bgcolor=cyan> <td><input type="radio" name="id2" value="<TMPL_VAR NAME="id2">"></td> <td><TMPL_VAR NAME="name"></td> </tr> </TMPL_LOOP> <form> </table> </body> </html>
戻る
夏邑县| 张家港市| 嘉荫县| 交城县| 高唐县| 观塘区| 江北区| 沙河市| 积石山| 北安市| 攀枝花市| 德令哈市| 比如县| 铁力市| 浏阳市| 宝兴县| 兴义市| 平远县| 科技| 寿阳县| 青龙| 通渭县| 大名县| 娄烦县| 定日县| 汉中市| 舟山市| 衡水市| 嵊州市| 昔阳县| 万宁市| 红原县| 五华县| 冀州市| 义马市| 鹤壁市| 临海市| 蕉岭县| 上栗县| 连南| 洪雅县|