That could get ugly if anything in @foo contains characters that should be escaped such as > or " ... something CGI.pm's popup_menu will handle for you automatically.
#!/usr/bin/perl -wT use strict; use CGI qw/:standard/; my %colours = ( '#008000' => 'Green', '#808000' => '> Olive', '#00FF00' => '> Lime', '#008080' => '> Teal', ); print header, popup_menu( -name => 'colour', -labels => \%colours, -values => [ sort keys %colours ], );
Also, if you're using DBI.pm and don't plan on labeling your <SELECT> values, then you can just pass in the output from DBI.pm's selectall_arrayref method.
print popup_menu( -name => 'colours' -values => $dbh->selectall_arrayref('SELECT name FROM colour'), );
--k.
In reply to Re: Re: mysql values in select box
by Kanji
in thread mysql values in select box
by drivle
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |