Does anyone know where I am going wrong in my attempt to use
selectall_hashref() to retrieve values from a database table for display in
a HTML Select construct or popup_menu()?
I am also have trouble retrieving the users selected value for writing back
to the database.
Also, should my code (i.e. the beginning stuff) appear in a better order?
#!/usr/bin/perl -w
use HTML::Template;
use strict;
use CGI qw(:standard);
use DBI;
my $mydbi = DBI->connect("...") or die "Could not connect";
my $template=HTML::Template->new(filename=>"homepage.html");
if ($template->query(name=>"advertisingsourceid_options"))
{
my $adsource_sql="SELECT ADVERTISING_SOURCE_ID,ADVERTISING_SOURCE FROM
ADVERTISING_SOURCE ORDER BY ADVERTISING_SOURCE";
my
$adsourceid_select_options=$mydbi->selectall_hashref($adsource_sql,'ADVERTIS
ING_SOURCE_ID');
$template->param(advertisingsourceid_options=>$adsourceid_select_options);
}
my ($AdvertisingSourceId) = param("advertisingsourceid");
'Submit $AdvertisingSourceId to various SQL statements (insert, update)
print "Content-Type: text/html\n\n",$template->output;
------------------
inner.html file
------------------
<TR><TD>Advertising Source:</TD>
<TD><SELECT NAME="advertisingsourceid">
<TMPL_VAR NAME=advertisingsourceid_options>
</SELECT></TD></TR>