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 .= "
"; return $ret; } _code?> <=body page?>