I spoke too soon, not quite there.

What I've got is a hash where they key is a record number and the value is text. I want to pass the keys as -values, but sorted by the hash values. Here's my code... no laughing please....

my %restaurants=&queryrestaurants; my @restaurantvalues=keys(%restaurants); print start_multipart_form(); print center(scrolling_list(-name=>'restauranttitle',-values=> +[@restaurantvalues],-default=>undef,size=>14,-multiple=>'false',-labe +ls=>\%restaurants),submit(-name=>'job',-value=>'edit'),submit(-name=> +'job',-value=>'new')); print endform; sub queryrestaurants { my (%restaurants,$restaurant,$address1,$address2,$zipcode,$phonenu +mber,$record); use DBI; my $dbh = DBI->connect("DBI:mysql:dbname:$sqlserver:3306","log +in","passwd"); my $sql_statement = "SELECT \* FROM location order by restaura +nt"; my $sth = $dbh->prepare($sql_statement); $sth->execute() or die "Can't execute SQL statement : $dbh->er +rstr"; $sth->bind_columns(undef, \$restaurant,\$address1,\$address2,\ +$zipcode,\$phonenumber,\$record); my $row; while ($row = $sth->fetchrow_arrayref) { $restaurants{$row->[5]}=$row->[0] . " " . $row->[1] . " \/ + " . $row->[3]; } $sth->finish; $dbh->disconnect; return %restaurants; }
I know the $restaurants{$row->[5]}=$row->[0] . " " . $row->[1] . " \/ " . $row->[3]; is a little convoluted, but I wanted to end up with:

<option value="42">Some Restaurant 200 Main St / 04444</option>

In reply to Re: Re: CGI.pm - scrolling_list and %labels hash by naChoZ
in thread CGI.pm - scrolling_list and %labels hash by naChoZ

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.