<div dir="ltr"><div>Hi Andrew,<br><br></div>the {} did the trick. Thank you VERY much. Was going out of my mind. <br></div><div class="gmail_extra"><br><div class="gmail_quote">2015-08-26 13:04 GMT-05:00 Andrew Beverley <span dir="ltr"><<a href="mailto:andy@andybev.com" target="_blank">andy@andybev.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Wed, 2015-08-26 at 12:39 -0500, Richard Reina wrote:<br>
> > > I have this table data that I load into a template as follows.<br>
> > ><br>
> > >   $q = "SELECT ID, NAME<br>
> > >                 FROM jobs<br>
> > >                 ORDER BY NAME";<br>
> > >        $sth = $dbh->prepare($q);<br>
> > >        $sth->execute();<br>
> > >        my $Jobs_ref = $sth->fetchall_hashref('ID');<br>
> ><br>
> > use fetchall_arrayref() instead.<br>
> ><br>
> > > To display it in the template as a drop-down select I do:<br>
> > ><br>
> > >     <select class="selectpicker" name="jobselect" id="jobselect"<br>
> > > style="width: 500px;"><br>
> > >               <% FOREACH ID IN Jobs.keys %><br>
> ><br>
> > Here you just need something like<br>
> ><br>
> >     FOREACH job in Jobs<br>
> ><br>
> > >         <option value="<% Jobs.$<a href="http://ID.ID" rel="noreferrer" target="_blank">ID.ID</a> %>"><% Jobs.$<a href="http://ID.NAME" rel="noreferrer" target="_blank">ID.NAME</a> %></option><br>
> ><br>
> > And then here use job.ID, job.NAME etc.<br>
><br>
</span><span class="">> Thank you for the replies.  I am guessing that keeping the sorting in the<br>
> SQL instead of the HTML would mean the page would load faster so I trying<br>
> to go that route.<br>
><br>
> However, when I switch my code above to:<br>
><br>
>     <% FOREACH job in Jobs %><br>
>         <option value="<% job.ID %>"><% Job.NAME %></option><br>
>         <% END %><br>
><br>
> I get an empty dropdown. I am using $sth->fetchall_arrayref(); with no<br>
> arguments.<br>
<br>
</span>You might need to do:<br>
<br>
    $sth->fetchall_arrayref({})<br>
<br>
Sorry, it's been a while since I've done direct DBI calls. I'd recommend checking<br>
out DBIx::Class if you have the time.<br>
<br>
If you're still not having any luck, dump the result to see what you've got:<br>
<br>
    use Data::Dumper;<br>
    say STDERR Dumper $Jobs_ref;<br>
<br>
Be careful of case-sensitivity, that could cause you problems too.<br>
<br>
Andy<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
<br>
_______________________________________________<br>
dancer-users mailing list<br>
<a href="mailto:dancer-users@dancer.pm">dancer-users@dancer.pm</a><br>
<a href="http://lists.preshweb.co.uk/mailman/listinfo/dancer-users" rel="noreferrer" target="_blank">http://lists.preshweb.co.uk/mailman/listinfo/dancer-users</a><br>
</div></div></blockquote></div><br></div>