mscdelete
戻る
#!C:/perl/bin/perl
######################################
# mscdelete.pl
######################################
use strict;
use DBI;
use CGI qw/:standard/;
use HTML::Template;
my ( %t, @rec, @loop, $n );
$t{q} = new CGI;
$t{enq1_id} = $t{q}->param("enq1_id");
$t{id1} = $t{q}->param("id1");
$t{item} = $t{q}->param("item");
$t{template} = HTML::Template->new(filename => 'mscdelete.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;
}
$t{name1id} = $t{dbh}->selectrow_array("select $t{item} from enq1 where id = $t{enq1_id}");
@{ $t{name1id_list} } = split(/==/,$t{name1id});
@{ $t{name1ids} } = ();
for $n ( 0 .. $#{ $t{name1id_list} } ) {
next if ( $t{name1id_list}[$n] == $t{id1} );
push(@{ $t{name1ids} },$t{name1id_list}[$n]);
}
$t{name1id_new} = join('==',@{ $t{name1ids} });
$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(DO => $t{DO});
$t{template}->param(sql => $t{name1id_new});
# send the obligatory Content-Type and print the template output
print $t{template}->output;
1;
-------------------------------------------------------------------------------
mscdelete
mscdelete
http://localhost/scripts/mscenq1_p.pl
ENQ_ID==>
DO==>
sql==>
戻る