while (my $ref = $sth->fetchrow_hashref ()) { ### NEW CODE ### # Start up a new query $clref = $dbh->prepare ("SELECT color FROM colors WHERE item_id = ".$ref->{item_id}); $clref->execute; # Push each new colour onto the array referenced by # $ref->{color} while (my $color = $clref->fetchrow_hashref()) { push @{$ref->{color}}, $color->{color}; } # Now $ref->{color} is an arrayref full of colours. ### ### ### ### my $serve_url = sprintf ("serve_image.cgi?item_id=%s;picture", escape ($ref->{item_id})); # generate a form allowing a quantity of the item to be added # to the cart push (@row, start_form(-method=>'POST', -action=>url())), hidden( -name => "choice", -override => 1, -default => "add" ), hidden( -name => "item_id", -override => 1, -default => escapeHTML($ref->{item_id})), Tr ({-style=>"font-family: verdana; font-size: 10pt;"}, td ( img ({-src => $serve_url, -alt => escapeHTML($ref->{item_id})}) ), td ({-width=>"80", -valign=>"top", -align => "center"}, escapeHTML( $ref->{item_id} ) ), td ({-width=>"190", -valign=>"top"}, escapeHTML( $ref->{description} ) ) ), Tr ({-style=>"font-family: verdana; font-size: 10pt;"}, td ({-colspan => "3", -align => "right", -style=>"font-weight: 700; color:blue;"}, "Price: \$", escapeHTML( sprintf( "%.2f", $ref->{price}) ) ) ), Tr ({-style=>"font-family: verdana; font-size: 10pt;"}, # Here is where you need to RTFM. At this point, # $ref->{color} is an arrayref. I suspect that # the popup_menu procedure will accept an array # reference as an argument, but I'm not sure. # Also, I'm too lazy to RTFM myself :o) In any # case, if you need to give it an array instead # you can dereference the arrayref. Check the # links below for how to do that. td ({-colspan => "3", -align => "right"}, "Colors:", popup_menu( -name => "color", -values => $ref->{color}) ) ), Tr ({-style=>"font-family: verdana; font-size: 10pt;"}, td ({-colspan => "3", -align => "right"}, "Quantity:", popup_menu( -name => "quantity", -values => ["1", "2", "3", "4", "5", "6", "7", "8", "9"]) ), td ( image_button( -name => "Add Item", -src=>"../images/add.jpg", -border=>"0" ) ) ), Tr ({-valign=>"top"}, td ({-colspan=>"7", -width=>"100%"}, hr ) ), end_form() ); }