<div dir="ltr"><div>Hi Attila,<br><br> <% FOREACH ID IN Jobs.keys.sort %><br>      <br></div><div>but multi-word lists do not appear exactly alphabetical as they do when MySQL sorts them by name.<br><br><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2015-08-26 12:43 GMT-05:00 Attila Bárdi <span dir="ltr"><<a href="mailto:attila.bardi@gmail.com" target="_blank">attila.bardi@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hey,<div><br></div><div>I’m using hash and sorting it from the template toolkit.</div><div>I would advise to try it then later you can play with the speed.</div><div><br></div><div>Best regards,</div><div>Attila</div><div><div class="h5"><div><br></div><div><br><div><blockquote type="cite"><div>On 26 Aug 2015, at 19:39, Richard Reina <<a href="mailto:gatorreina@gmail.com" target="_blank">gatorreina@gmail.com</a>> wrote:</div><br><div><div dir="ltr"><div><div>Andrew and Attilla,<br><br></div>Thank you for the replies.  I am guessing that keeping the sorting in the SQL instead of the HTML would mean the page would load faster so I trying to go that route.<br> <br></div><div>However, when I switch my code above to:<br></div><br>    <% FOREACH job in Jobs %><br>        <option value="<% job.ID %>"><% Job.NAME %></option><br>        <% END %><br><div class="gmail_extra"><br></div><div class="gmail_extra">I get an empty dropdown. I am using $sth->fetchall_arrayref(); with no arguments. Sorry to ask, but been playing with it for over an hour and still have it figured it out.<br><br></div><div class="gmail_extra"><br><div class="gmail_quote">2015-08-26 9: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:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span>On Wed, 2015-08-26 at 08:51 -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>
</span>use fetchall_arrayref() instead.<br>
<span><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>
</span>Here you just need something like<br>
<br>
    FOREACH job in Jobs<br>
<span><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>
</span>And then here use job.ID, job.NAME etc.<br>
<span><br>
> And it works great. Except for one thing, the list is not in order by name.<br>
> I have read more than a few posts about how once you save a query as a<br>
> hashref that the order is lost.<br>
<br>
</span>Yes, in Perl arrays are ordered, hashes are not. If you want to retain order, you<br>
must use an array (or sort the hash before use, which is expensive).<br>
<span><br>
>  Most of those posts suggested fetching as a<br>
> arrayref instead. However, I have no idea how to do that and then display<br>
> it in a select like the above code does.<br>
<br>
</span>See above.<br>
<br>
<br>
_______________________________________________<br>
dancer-users mailing list<br>
<a href="mailto:dancer-users@dancer.pm" target="_blank">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>
</blockquote></div><br></div></div>
_______________________________________________<br>dancer-users mailing list<br><a href="mailto:dancer-users@dancer.pm" target="_blank">dancer-users@dancer.pm</a><br><a href="http://lists.preshweb.co.uk/mailman/listinfo/dancer-users" target="_blank">http://lists.preshweb.co.uk/mailman/listinfo/dancer-users</a><br></div></blockquote></div><br></div></div></div></div><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>
<br></blockquote></div><br></div>