Dear Monks,
I've set up a scrolling list which calls the names of various items from a database. I had thought that I'd written the code so that the sorted list will appear as a list but it comes out as a row (that is I get foo bar baz instead of
foo
bar
baz).
This is the first form that I've created from scratch (most of the other stuff is pure maintenance) so I'd be grateful if someone could let me know what I've done incorrectly.
#!c:\perl\bin\perl.exe
use strict;
use warnings;
use CGI;
use DBI;
#calling the service overview tables
my $q= new CGI;
print $q->header();
print $q->start_html(-title=>'service metrics');
print qq[<form method="post"action="/cgi-bin/service.pl" name="metric"
+>];
#code to create the scroll down box which selects from the db
my $db = DBI->connect(foo, bar, baz
{RaiseError => 1, AutoCommit => 1});
my $sth = $db->prepare("SELECT Name FROM service_metrics");
$sth->execute;
my @data;
while (my @result = $sth->fetchrow_array)
{
push @data,$result[0];
}
print $q->scrolling_list(-name=>"metrics", -value=>"@data");
$sth->finish;
$db->disconnect();
print $q->submit(-value=>"Choose");
print qq[</form>];
Many thanks for your help,
Iain
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.