vxp has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use DBI; use CGI qw/:standard *table start_ul/; $db_host = "localhost"; $db_user = "myuser"; $db_pass = "mypass"; my $dbh = DBI->connect("DBI:mysql:database=fnoofs;host=$db_host", $db_ +user, $db_pass, {'RaiseError' => 1}); opendir(DIR, "/web/htdocs/images/fnoofus") or die "wtf.. $!"; @allfiles = grep { $_ ne '.' and $_ ne '..' } readdir DIR; closedir DIR; print header, start_html('Fnoofus Admin Page'), start_form; $num = 0; print "begin foreach loop<br>"; foreach $file (@allfiles) { print "incrementing num<br>"; $num++; @checkname[$num] = $file . "_db"; $sth = $dbh->prepare("select * from fnoofus where picname='$file +'"); $number = $sth->execute(); print "<br>begin if loop<br>"; if ($number > 0) { print "begin while loop<br>"; while (@row = $sth->fetchrow_array) { print "<table>"; print "<tr><td rowspan=\"4\">"; print "<img src=\"/images/fnoofus/$file\"></td>"; print "<td valign=\"top\">"; print "Image location: ", textfield(-name=>'imageLoc',-defa +ult=>$row[1],-size=>50,-maxlength=>80),p; print "</td></tr><tr><td>"; print "Description: ", textfield(-name=>'description',-defa +ult=>$row[2],-size=>55),p; print "</td></tr><tr><td>"; print "Picname: ", textfield(-name=>'picname',-default=>$ro +w[3],-size=>20),p; print "</td></tr><tr><td valign=\"top\">"; print checkbox(-name=>$checkname[$num],-checked=>1,-value=> +'ON'); print "</td></tr>"; print "</table>", hr; } } else { print "<table>"; print "<tr><td rowspan=\"4\">"; print "<img src=\"/images/fnoofus/$file\"></td>"; print "<td valign=\"top\">"; print "Image location: ", textfield(-name=>'imageLoc',-defa +ult=>'nothing here',-size=>50,-maxlength=>80),p; print "</td></tr><tr><td>"; print "Description: ", textfield(-name=>'description',-defa +ult=>'nothing here',-size=>55),p; print "</td></tr><tr><td>"; print "Picname: ", textfield(-name=>'picname',-default=>'no +thing here',-size=>20),p; print "</td></tr><tr><td valign=\"top\">"; print checkbox(-name=>$checkname[$num],-checked=>0,-value=> +'OFF'); print "</td></tr>"; print "</table>", hr; } } print submit, end_form; if (param()) { foreach $check (@checkname) { if (param($check)) { print "$check<br>"; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: variables get overwritten (loop problem? i dunno)
by gjb (Vicar) on Jan 04, 2003 at 04:37 UTC | |
by Anonymous Monk on Jan 04, 2003 at 05:35 UTC | |
by gjb (Vicar) on Jan 04, 2003 at 09:00 UTC | |
|
Re: variables get overwritten (loop problem? i dunno)
by Anonymous Monk on Jan 04, 2003 at 04:10 UTC | |
|
Re: variables get overwritten (loop problem? i dunno)
by Anonymous Monk on Jan 04, 2003 at 04:17 UTC |