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==>
-------------------------------------------------------------------
戻る
图们市|
黔西县|
江安县|
金阳县|
盐城市|
祥云县|
阿勒泰市|
明水县|
内乡县|
陆丰市|
盐边县|
浦北县|
闸北区|
武强县|
武功县|
偃师市|
宁国市|
阿拉善盟|
新晃|
十堰市|
井冈山市|
辛集市|
石门县|
东阳市|
曲靖市|
丽水市|
枣阳市|
临潭县|
开封县|
九龙县|
文化|
漳浦县|
沈丘县|
那坡县|
湛江市|
宣恩县|
合川市|
嘉兴市|
迁安市|
聊城市|
温宿县|