#!/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
"; foreach $file (@allfiles) { print "incrementing num
"; $num++; @checkname[$num] = $file . "_db"; $sth = $dbh->prepare("select * from fnoofus where picname='$file'"); $number = $sth->execute(); print "
begin if loop
"; if ($number > 0) { print "begin while loop
"; while (@row = $sth->fetchrow_array) { print ""; print ""; print ""; print "
"; print ""; print "Image location: ", textfield(-name=>'imageLoc',-default=>$row[1],-size=>50,-maxlength=>80),p; print "
"; print "Description: ", textfield(-name=>'description',-default=>$row[2],-size=>55),p; print "
"; print "Picname: ", textfield(-name=>'picname',-default=>$row[3],-size=>20),p; print "
"; print checkbox(-name=>$checkname[$num],-checked=>1,-value=>'ON'); print "
", hr; } } else { print ""; print ""; print ""; print "
"; print ""; print "Image location: ", textfield(-name=>'imageLoc',-default=>'nothing here',-size=>50,-maxlength=>80),p; print "
"; print "Description: ", textfield(-name=>'description',-default=>'nothing here',-size=>55),p; print "
"; print "Picname: ", textfield(-name=>'picname',-default=>'nothing here',-size=>20),p; print "
"; print checkbox(-name=>$checkname[$num],-checked=>0,-value=>'OFF'); print "
", hr; } } print submit, end_form; if (param()) { foreach $check (@checkname) { if (param($check)) { print "$check
"; } } }