T-shirt poll body<= login."; } my %pro = ('short' => 'Short-sleeved', 'long' => 'Long-sleeved', 'baby' => 'Baby Doll', 'polo' => 'Embroidered Polo'); my %col = ('black' => "Black", 'gray' => "Gray", 'blue' => "Royal Blue"); my @sizes = qw(S M L XL XXL XXXL); # no /XX+/ for baby doll if (LJ::did_post()) { $dbh->do("DELETE FROM tshirtpoll WHERE userid=?", undef, $remote->{'userid'}); my @values; foreach my $style (keys %pro) { foreach my $col (keys %col) { foreach my $size (@sizes) { my $k = "${style}_${col}_${size}"; if ($POST{$k} =~ /^\d+$/) { push @values, "($remote->{'userid'}, '$style', '$col', '$size', $POST{$k})"; } } } } if (@values) { $dbh->do("REPLACE INTO tshirtpoll (userid,style,color,size,qty) ". "VALUES " . join(',', @values)); return $dbh->errstr if $dbh->err; } return ""; } my %prefill; my $sth = $dbh->prepare("SELECT style, color, size, qty FROM tshirtpoll WHERE userid=?"); $sth->execute($remote->{'userid'}); while (my ($st, $c, $si, $qt) = $sth->fetchrow_array) { $prefill{"${st}_${c}_${si}"} = $qt; } my $ret; $ret .= ""; $ret .= "

"; $ret .= ""; foreach (@sizes) { $ret .= ""; } $ret .= "\n"; foreach my $style (qw(short long baby polo)) { foreach my $color (qw(black gray blue)) { $ret .= ""; foreach my $size (@sizes) { $ret .= ""; } $ret .= "\n"; } } $ret .= "
Type / Color$_
$pro{$style} ($col{$color})"; unless ($style eq "baby" && $size =~ /XX+/) { my $k = "${style}_${color}_${size}"; $ret .= ""; } else { $ret .= "--"; } $ret .= "
"; return $ret; } _code?> <=body page?>