my $sth = $dbh->prepare("SELECT id, filename, title FROM pictures"); $sth->execute(); print "
| "; my $pic = $sth->fetchrow_hash; if ($pic) { # emit html for the image # data for the picture is in hashref $pic, i.e.: # $pic->{id}, $pic->{filename} and $pic->{title} } else { # emit html for an empty cell } print " | "; } print "