|
The script is as follows: |
#!/usr/bin/perl use DBI(); use CGI;
my $dbh = DBI->connect("DBI:mysql:database=$mydatabase;host=$myhost",
$mylogin, $mypassword,
{'RaiseError' => 1});
###################query#####################################
# get sections from the table $query = "select name from request_type order by name asc;";
$sth=$dbh->prepare($query) || die "error: $DBI::errstr\n"; $sth->execute() || die "error: $DBI::errstr\n";
# print options for combo box, in a loop
while ($pointer = $sth->fetchrow_hashref){ $sect = $pointer->{'name'};
$mycategories = $mycategories.'<option>'.$sect;
}
print <<END; Content-Type: text/html\n\n
<html>
<h2> Test Form with mysql</h2> <FORM NAME="Table1FORM" ACTION="$serviceviewurl" METHOD=POST>
<p>Combo Box with values from <b>request_type<b> table <SELECT NAME="category" size="1">$mycategories</select>
<p><input type="submit" border="0" name="Action">
</FORM>
</html> END |