mscupdate
戻る
#!C:/perl/bin/perl
######################################
# mscupdate.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{id1} = $t{q}->param("id1");
$t{table} = $t{q}->param("table");
$t{item} = $t{q}->param("item");
$t{template} = HTML::Template->new(filename => 'mscupdate.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;
}
if ( $t{id1} != 0 ) {
$t{name1id} = $t{dbh}->selectrow_array("select $t{item} from enq1 where id = $t{enq1_id}");
if ( $t{name1id} ) {
$t{name1id_new} = $t{name1id} . '==' . $t{id1};
} else {
$t{name1id_new} = $t{id1};
}
$t{sql} = 'UPDATE enq1 set ' . $t{item} . ' = "';
$t{sql} .= $t{name1id_new} . '" where id = ';
$t{sql} .= $t{enq1_id};
$t{DO} = $t{dbh}->do($t{sql});
}
$t{dbh}->disconnect;
$t{template}->param(enq1_id => $t{enq1_id});
$t{template}->param(id1 => $t{id1});
$t{template}->param(table => $t{table});
$t{template}->param(DO => $t{DO});
$t{template}->param(sql => $t{sql});
if ( $t{DO} ) {
$t{template}->param(OK1 => 1);
$t{template}->param(OK2 => 0);
} else {
$t{template}->param(OK1 => 0);
$t{template}->param(OK2 => 1);
}
# send the obligatory Content-Type and print the template output
print $t{template}->output;
1;
-------------------------------------------------------------------------------
mscupdate
mscupdate
http://localhost/scripts/mscenq1_p.pl
ENQ_ID==>
id1==>
DO==>
sql==>
成功しました。上のmscenq1_p.plをクリックしてください。
選択していません。上の「戻る」をクリックしてください。
戻る