It's just text fields with a numeric name and one submit button.
What I need to do is find a way to store all these numeric params into a hash (as I assume this is the best way?) and then update a mysql every numeric name (which is actually called pic_id in the database) with the value of that parameter.
Anyone have thoughts on how to do this? I could in theory parse the database before I collect the form params (after it was submitted) and get the available pic_ids that I expect and make each their own variable. Then get the form params in their own scalar. But I doubt that's the best way.
# assuming $cgi = new CGI;
# prepare update query
my $sth = $dbh->prepare(' update pic_table set pic_value=? where pic_id=? ');
# loop over all param names, and
# grep out all those that are numerical
foreach my $p( grep /^\d+$/, $cgi->param) {
# find the form value
my $v = $cgi->param( $p );
# execute the query
$sth->execute( $v, $p );
}
foreach my $p( grep /^\d+$/, param() ) {
# find the form value
my $v = param( $p );
# execute the query
$sth->execute( $v, $p );
}
Note that DBI still uses OOP :)
perlmonks.org content © perlmonks.org and Anonymous Monk, rhesa
prlmnks.org © 2006 edmund von der burg (eccles & toad)
v 0.03