use CGI qw/:all/;
| much handwaving
|
foreach my $row ($dbh->fetchrow_hashref){
print start_form ( -action => "crudscript.pl" );
print hidden('row_id',$row->{row_id});
printf "Old Name: %s",$row->{name};
printf "New Name: %s",texfield('newname','');
printf submit('action','delete');
printf submit('action','update');
print "
";
}
####
#!/usr/bin/perl -w
use strict;
use feature 'switch'; #only works in newer versions (5.10?) of Perl
use CGI qw/ :all /;
|
| Handwaving here.
|
my $cgi=CGI->new();
my $action = $cgi->param('action');
given ($action){
when('delete'){
my $row_id = $cgi->param('row_id');
| insert code here to delete a row based on its id
}
when('update'){
my $newname = $cgi->param('newname');
if ($newname) { # non-null input only
| code here to execute update
}
|
}