Okay, I've made an attempt to make the code easier to understand by cleaning it up. Now have a look at the HTML that is generated by this code and you'll see how to get at the information for those images that have been selected using the checkboxes.
Hope this helps, -gjb-
#!perl use strict; use warnings; use CGI::Pretty qw( :standard ); use DBI; $CGI::Pretty::INDENT = " "; my $cgi = CGI::Pretty->new(); my $db_host = "localhost"; my $db_user = "myuser"; my $db_pass = "mypass"; my $dbh = DBI->connect("DBI:mysql:database=fnoofs;host=$db_host", $db_user, $db_pass, {'RaiseError' => 1}); my $sth = $dbh->prepare("SELECT * FROM fnoofus WHERE picname='?'"); opendir(DIR, "/web/htdocs/images/fnoofus") or die "wtf.. $!"; @all_files = grep { $_ ne '.' and $_ ne '..' } readdir DIR; closedir DIR; print header; print start_html("Test page"); print start_form; foreach my $file (@all_files) { my $number = $sth->execute($file); my @row; if ($number > 0) { @row = $sth->fetchrow_array(); } else { @row = ('nothing here') x 4; } print table(TR(td({rowspan => "4"}, img({src => "somepath/$file"})), td({valign => "top"}, "Image location: ", textfield({name => "imageLoc_$file", default => $row[1], size => 50, maxlength => 80}))), TR(td("Description: ", textfield({name => "description_$file", default => $row[2], size => 55}))), TR(td("Picname: ", textfield({name => "picname_$file", default => $row[3], size => 20}))), TR(td({valign => "top"}, checkbox({name => $file . '_db', checked => 1, value => "ON"})))); print hr; } print submit; print end_form; print end_html;
In reply to Re: Re: Re: variables get overwritten (loop problem? i dunno)
by gjb
in thread variables get overwritten (loop problem? i dunno)
by vxp
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |