数据库搜索的界面和程序

戻る

mscengine_nm.pl

sub mscengine_nm { my $self = shift; my(%t,$q,$template,$table,@rec); # Get CGI query object $q = $self->query(); $t{html} = $q->param("tmpl"); $t{html} = $t{html} . '.htm'; $template = $self->load_tmpl("$t{html}") || die "error loading tmpl"; $t{title} = $q->param("title"); $t{table} = $q->param("table"); $t{id} = $q->param("id"); $t{item} = $q->param("item"); $t{sth} = $self->dbh->prepare("SELECT id,name FROM $t{table}"); $t{sth}->execute; while ( @rec = $t{sth}->fetchrow_array ) { my $row_ref = (); # この初期化はとても重要! $$row_ref{id} = $rec[0]; $$row_ref{Line} = $rec[1]; push(@loop, $row_ref); } $t{sth}->finish; $template->param(aid => $t{id}); $template->param(title => $t{title}); $template->param(item => $t{item}); $template->param(THIS_LOOP => \@loop); return $template->output; } 1;

mscengine_nm.htm

<HTML> <HEAD> <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> <TITLE>主機の<TMPL_VAR NAME="title">選択</TITLE> <style type="text/css"> body { background: lightcyan; color:black; margin-left:2em;margin-right:2em;} </style> </HEAD> <BODY> <center> <h2>主機の<TMPL_VAR NAME="title">選択</h2></center> mode:modeengine_nm <form action="" method="post"> <input type="submit" value="主機テーブル管理へ戻る"><p> <input type="hidden" name="tmpl" value="msc261"> <input type="hidden" name="table" value="main_type1"> <input type="hidden" name="items" value="id,name,series,gname_id,maker_id,GR,DWG,memo"> <input type="hidden" name="rm" value="modeshowall"> </form> <hr color="#003366"> aid==><TMPL_VAR NAME="aid"> <form action="" method="post"> <input type="submit" value="选择"><p> <TMPL_LOOP NAME="this_loop"> <INPUT TYPE="radio" NAME="id" VALUE=<TMPL_VAR NAME="id">><TMPL_VAR NAME="id">,<TMPL_VAR NAME="Line"><br> </TMPL_LOOP> <input type="hidden" name="tmpl" value="mscengine_nm1"> <input type="hidden" name="title" value="<TMPL_VAR NAME="title">"> <input type="hidden" name="aid" value="<TMPL_VAR NAME="aid">"> <input type="hidden" name="item" value="<TMPL_VAR NAME="item">"> <input type="hidden" name="rm" value="modeengine_nm1"> </form> <hr color="#003366"> </BODY> </HTML>

mscengine_nm1.pl

sub mscengine_nm1 { my $self = shift; my(%t,$q,$template,$table,@rec); # Get CGI query object $q = $self->query(); $t{html} = $q->param("tmpl"); $t{html} = $t{html} . '.htm'; $template = $self->load_tmpl("$t{html}") || die "error loading tmpl"; $t{title} = $q->param("title"); $t{aid} = $q->param("aid"); $t{id} = $q->param("id"); $t{item} = $q->param("item"); $t{sql} = 'UPDATE main_type1 set ' . $t{item} . ' = "'; $t{sql} .= $t{id} . '" where id = ' . $t{aid}; $t{DO} = $self->dbh->do($t{sql}); $template->param(aid => $t{aid}); $template->param(id => $t{id}); $template->param(sql => $t{sql}); $template->param(DO => $t{DO}); $template->param(title => $t{title}); return $template->output; } 1;

mscengine_nm1.htm

<HTML> <HEAD> <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> <TITLE>主機の<TMPL_VAR NAME="title">選択確定</TITLE> <style type="text/css"> body { background: lightcyan; color:black; margin-left:2em;margin-right:2em;} </style> </HEAD> <BODY> <center> <h2>主機の<TMPL_VAR NAME="title">選択確定</h2></center> mode:modeengine_nm1 <form action="" method="post"> <input type="submit" value="主機テーブル管理へ戻る"><p> <input type="hidden" name="tmpl" value="msc261"> <input type="hidden" name="table" value="main_type1"> <input type="hidden" name="items" value="id,name,series,gname_id,maker_id,GR,DWG,memo"> <input type="hidden" name="rm" value="modeshowall"> </form> <hr color="#003366"> aid==><TMPL_VAR NAME="aid"><br> id==><TMPL_VAR NAME="id"><br> sql==><TMPL_VAR NAME="sql"><br> DO==><TMPL_VAR NAME="DO"><br> <hr color="#003366"> </BODY> </HTML>

mscs_engine.pl

sub mscs_engine { my $self = shift; my(%t,$n,@loop,@rec); # Get CGI query object $t{q} = $self->query(); $t{table} = $t{q}->param("table"); $t{item} = $t{q}->param("item"); $t{enq1_id} = $t{q}->param("enq1_id"); $t{word} = $t{q}->param("word1"); $t{word} = lc($t{word}); @loop = (); $t{NO} = 0; $t{sth} = $self->dbh->prepare("SELECT id,name FROM $t{table}"); $t{sth}->execute; while ( @rec = $t{sth}->fetchrow_array ) { $t{name} = lc($rec[1]); if ( $t{name} =~ /$t{word}/ ) { my $row_ref = (); # この初期化はとても重要! $$row_ref{id} = $rec[0]; $$row_ref{Line} = $rec[1]; push(@loop, $row_ref); $t{NO}++; } } $t{sth}->finish; $t{template} = $self->load_tmpl("mscs_engine.htm") || die "error loading tmpl"; if ( $t{NO} == 0 ) { $t{template}->param(explain => "データはありません。「戻る」をクリック"); } else { $t{template}->param(explain => "1つを選択してから,「追加」をクリック"); $t{template}->param(THIS_LOOP => \@loop); } $t{template}->param(pro => "mscs_engine.pl"); $t{template}->param(table => $t{table}); $t{template}->param(enq1_id => $t{enq1_id}); $t{template}->param(item => $t{item}); return $t{template}->output; } 1;

mscs_engine.htm

<HTML> <HEAD> <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> <TITLE>mscs_engine</TITLE> <style type="text/css"> body { background: lightcyan; color:black; margin-left:2em;margin-right:2em;} </style> </HEAD> <BODY> mode:mscs_engine;Perl:<TMPL_VAR NAME="pro">;table:<TMPL_VAR NAME="table"><br><br> <TMPL_VAR NAME="explain">,<form action="" method="post"> <input type="submit" value="戻る"><p> <input type="hidden" name="id" value=<TMPL_VAR NAME="enq1_id">> <input type="hidden" name="rm" value="modeenq1_engine"> </form> <br> enq1_id==><TMPL_VAR NAME="enq1_id"><br> item==><TMPL_VAR NAME="item"><br> <hr color="#003366"> <form action="" method="post"> <input type="submit" value="追加"><p> <TMPL_LOOP NAME="this_loop"> <INPUT TYPE="radio" NAME="id" VALUE=<TMPL_VAR NAME="id">><TMPL_VAR NAME="id">,<TMPL_VAR NAME="Line"><br> </TMPL_LOOP> <input type="hidden" name="enq1_id" value=<TMPL_VAR NAME="enq1_id">> <input type="hidden" name="item" value=<TMPL_VAR NAME="item">> <input type="hidden" name="rm" value="modeu_engine"> </form> <hr color="#003366"> </BODY> </HTML>
戻る