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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.