戻る
------------------------------------------------------------------------
my $template = HTML::Template->new(filename => 'test_parts.htm');
------------------------------------------------------------------------
test_parts.htm
------------------------------------------------------------------------
$t{q} = new CGI;
$t{NO} = $t{q}->param("NO");
$t{template} = HTML::Template->new(filename => 'test_parts2.htm');
@loop = (); # initialize an array to hold your loop
for $n ( 1 .. 10 ) {
$t{Name} = 'OK' . $n;
if ( $t{NO} == $n ) {
$t{$t{Name}} = 1;
} else {
$t{$t{Name}} = 0;
}
$t{template}->param($t{Name} => $t{$t{Name}});
}
$t{template}->param(NO => $t{NO});
# send the obligatory Content-Type and print the template output
print $t{template}->output;
------------------------------------------------------------------------
NO==>
OK1=>
OK2=>
OK3=>
OK4=>
OK5=>
OK6=>
OK7=>
OK8=>
OK9=>
OK10=>
--------------->
主機タイプは1個である。
主機タイプは2個である。
主機タイプは3個である。
主機タイプは4個である。
主機タイプは5個である。
主機タイプは6個である。
主機タイプは7個である。
主機タイプは8個である。
主機タイプは9個である。
主機タイプは10個である。
------------------------------------------------------------------------
If you called "param()" with a value like sam"my you'll get in trouble
with HTML's idea of a double-quote. On the other hand, if you use
ESCAPE=HTML, like this:
">
You'll get what you wanted no matter what value happens to be passed in
for param. You can also write ESCAPE="HTML", ESCAPE='HTML' and
ESCAPE='1'.
If the name of a TMPL_LOOP is used in a TMPL_IF, the IF block will
output if the loop has at least one row. Example:
This will output if the loop is not empty.
....
------------------------------------------------------------------------
use strict;
use CGI qw/:standard/;
use HTML::Template;
my ( %t, @fld, $sql, @rec, @rows, @rowsa, @rowsb );
my $template = HTML::Template->new(filename => 'tmp_if.htm');
$t{OK} = 0;
if ( $t{OK} ) {
$t{OK1} = 1;
$t{OK2} = 0;
} else {
$t{OK1} = 0;
$t{OK2} = 1;
}
$template->param(OK1 => $t{OK1});
$template->param(OK2 => $t{OK2});
# send the obligatory Content-Type and print the template output
print $template->output;
----------------------------------------------------------------
OK1=
OK2=
--------------->
データベースの項目追加が成功しました。
データベースの項目追加が失敗しました。
戻る 西宁市|
邵武市|
榆树市|
赤峰市|
汽车|
邳州市|
株洲市|
梁平县|
榆社县|
抚州市|
新乐市|
阜城县|
高碑店市|
昌都县|
牡丹江市|
苗栗市|
石首市|
瑞安市|
台北县|
舞阳县|
河北省|
海口市|
兴安盟|
定西市|
灵璧县|
通渭县|
太原市|
高清|
常山县|
汤阴县|
灵武市|
贡嘎县|
南投市|
青海省|
徐汇区|
邵武市|
蒙阴县|
贺州市|
垫江县|
确山县|
南靖县|