davies has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to populate a CGI scrolling list using the return from a database query. The relevant part of the code is:
my $doclist = $dbh->selectall_arrayref( q{SELECT name FROM products}); my $q = CGI->new; print $q->header, $q->start_html('Edit comments'), $q->h1('Edit Comments'); print scalar(@$doclist); print scrolling_list(-name => 'cboProj', -values => @$doclist);
This tells me that here are two values being returned (the correct number), but only the first appears in the list. I have tried various forms of dereferencing, but although some of these put two lines in the list, they are all of the form of a reference rather than the data that are in the database. I suspect I'm barking up the wrong tree with dereferencing, but I can't find any suggestions of what to try beyond the CGI documentation, which puts hard coded values in by using square brackets (one of the things that gives two lines of the ARRAY(0x*) type). Can anyone point me at some decent documentation for this, please?
Regards,
John Davies
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Populating a CGI scrolling list from a database
by moritz (Cardinal) on Feb 15, 2011 at 16:13 UTC | |
by davies (Monsignor) on Feb 15, 2011 at 16:27 UTC | |
|
Re: Populating a CGI scrolling list from a database
by Anonyrnous Monk (Hermit) on Feb 15, 2011 at 16:14 UTC |