CGI プログラム7
戻る
# ourrefの自動生成
use strict;
use DBI;
use CGI qw/:standard/;
use HTML::Template;
my ( $dsn, $dbh, $sth, $no );
my ( %t, @fld, $sql, @rec, @rows, @rowsa, @rowsb );
my $template = HTML::Template->new(filename => 'mscenq1.htm');
my @loop = (); # initialize an array to hold your loop
$dsn = "DBI:mysql:host=localhost;database=cookbook";
$dbh = DBI->connect($dsn, "cbuser", "cbpass") or die "Cannot connect to server\n";
$dbh->do("SET NAMES utf8");
if(!$dbh){
print "SQL read ERROR!\n";
exit;
}
$t{ourref_maxid} = $dbh->selectrow_array("select max(id) from our_ref");
$t{ourref1} = $dbh->selectrow_array("select ourref from our_ref where id = $t{ourref_maxid}");
$dbh->disconnect;
# 今日の日付
($t{day},$t{month},$t{year}) = (localtime)[3,4,5];
$t{year} = substr($t{year},-1);
$t{month} = $t{month} + 1;
$t{month} = sprintf("%02d",$t{month});
$t{day} = sprintf("%02d",$t{day});
$t{ourref2} = $t{year} . $t{month} . $t{day} . '000';
$t{tmp1} = substr($t{ourref1},-3);
if ( $t{tmp1} eq '999' ) { # 最大は999
$t{ourref0} = $t{ourref1};
$t{ourref0_OK} = 'NG';
} elsif ( ($t{ourref1} - $t{ourref2}) >= 0 ) {
$t{ourref0} = $t{ourref1} + 1;
$t{ourref0_OK} = 'OK';
} else {
$t{ourref0} = $t{ourref2};
$t{ourref0_OK} = 'OK';
}
$template->param(ourref1 => $t{ourref1});
$template->param(ourref0 => $t{ourref0});
$template->param(ourref0_OK => $t{ourref0_OK});
# send the obligatory Content-Type and print the template output
print $template->output;
-------------------------------------------------------------------
---------------------------------------------------
use strict;
use CGI qw/:standard/;
use HTML::Template;
my (%t);
$t{q} = new CGI;
$t{name} = $t{q}->param("NAME");
$t{template} = HTML::Template->new(filename => 'mscenq2.htm');
$t{template}->param(name => $t{name});
# データ出力
print $t{template}->output;
---------------------------------------------------
name==>
-------------------------------------------------------------------
戻る
墨脱县|
泾源县|
河池市|
广宗县|
武城县|
丰县|
思茅市|
邵武市|
大埔区|
广元市|
卢湾区|
岚皋县|
吉首市|
密云县|
德安县|
德令哈市|
濮阳县|
三河市|
通山县|
长白|
白城市|
扶绥县|
喀什市|
依兰县|
勐海县|
松桃|
阿勒泰市|
巢湖市|
楚雄市|
盈江县|
若羌县|
唐海县|
阿鲁科尔沁旗|
鹤岗市|
贺州市|
洛隆县|
出国|
三河市|
潞城市|
武义县|
泰兴市|