powerhouse has asked for the wisdom of the Perl Monks concerning the following question:
Then $option_list would have my option list. However, I am going to use it for anywhere from 10 to 100 different forms on each page, depending on the setting, and each one will have a different default, so how can I put it in a hash or array, where I can use CGI.pm's popup_menu? Here is what I want to be able to do, something like this:while (my $something = $sth->fetchrow_hashref()) { $option_list .= qq~<option value="~ . $something->{id} . qq~">~ . + $something->{cat_name} . qq~</option>\n~; }
Something like that. Of course, it would be customized to my scripting style, but that is way I'm trying to pull the data out of the database.popup_menu(-name=>"somename1", -values=>[%options], -labels=>[\%options], -default=>$somename1_value);
That does not work. ;($sth1 = $dbh->prepare (qq{ SELECT * FROM categories }); $sth1->execute(); %cat_options = (); while (my $oc111 = $sth1->fetchrow_hashref()) { $cat_options{$oc111->{id}} = $oc111->{c_name}; } $sth1->finish(); # And for the popup_menu: popup_menu(-name=>"cid", -values=> [%cat_options], -labels=>{\%cat_options}, -default=>$row->{cid}, -class=>"formfield_left")
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: popup_menu from database
by dws (Chancellor) on Apr 06, 2003 at 04:34 UTC | |
by powerhouse (Friar) on Apr 06, 2003 at 04:44 UTC | |
by Enlil (Parson) on Apr 06, 2003 at 06:43 UTC | |
by powerhouse (Friar) on Apr 06, 2003 at 13:01 UTC |