mscsearch

戻る

#!C:/perl/bin/perl ###################################### # mscsearch.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{table} = $t{q}->param("table"); $t{item} = $t{q}->param("item"); $t{template} = HTML::Template->new(filename => 'mscsearch.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 $t{table}"); $t{sth}->execute; @loop = (); while (@rec = $t{sth}->fetchrow_array) { my %row = ( id => $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(table => $t{table}); $t{template}->param(item => $t{item}); # 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>mscsearch</title> <head> <body bgcolor="#fcf5ca"> <h2>mscsearch</h2> <a href="http://localhost/scripts/mscenq1_p.pl">http://localhost/scripts/mscenq1_p.pl</a> <hr> ENQ_ID==><TMPL_VAR NAME="enq1_id"> <table> <tr bgcolor=white> <th>Radio</th> <th>name</th> </tr> <form method="POST" action="mscupdate.pl"> <input type="submit" value="選択したデータを追加">==>http://localhost/scripts/mscupdate.pl <input type="hidden" name="enq1_id" value="<TMPL_VAR NAME="enq1_id">"> <input type="hidden" name="table" value="<TMPL_VAR NAME="table">"> <input type="hidden" name="item" value="<TMPL_VAR NAME="item">"> <TMPL_LOOP NAME="THIS_LOOP"> <tr bgcolor=cyan> <td><input type="radio" name="id1" value="<TMPL_VAR NAME="id">"></td> <td><TMPL_VAR NAME="name"></td> </tr> </TMPL_LOOP> <form> </table> </body> </html>
戻る
扎囊县| 岳西县| 漠河县| 股票| 隆回县| 德化县| 独山县| 喀喇沁旗| 县级市| 开封市| 繁峙县| 吴旗县| 临安市| 宁化县| 曲阜市| 梁山县| 崇文区| 江都市| 宁明县| 确山县| 平利县| 思茅市| 房产| 肃北| 淮南市| 元朗区| 泸西县| 乌兰浩特市| 鸡西市| 京山县| 简阳市| 惠东县| 马边| 衡阳县| 昂仁县| 乐安县| 大港区| 胶南市| 洛扎县| 柳江县| 溧水县|