[Chicago-talk] Concactenate results from perl DBI fetchall_hashref

Richard Reina gatorreina at gmail.com
Wed Aug 26 05:22:42 PDT 2015


Imran,

Thank you very much for your reply.  Your first solution worked perfectly.

Thanks again.

2015-08-24 11:26 GMT-05:00 imran javaid <imranjj at gmail.com>:

> There is more than one way to skin this cat.
>
> Did you try this?
> <label><input type="checkbox" value="<% Accomp.$ID.ID <http://id.id/> %>"><%
> Accomps.$ID.NAME <http://id.name/> %><% Accomps.$ID. <http://id.name/>
> descrip %></label>
>
> or you could change query:
> my $q = "SELECT ID, NAME, descrip, NAME || descrip as COMBINED
>                 FROM accomp_type
>                 WHERE repair = ?
>                 ORDER BY NAME";
> and refer to it as:
> <label><input type="checkbox" value="<% Accomp.$ID.ID <http://id.id/> %>"><%
> Accomps.$ID. <http://id.name/>COMBINED %></label>
>
> Note that in either case, there is no space between NAME and descrip. You
> can add that if you want.
>
> -imran
>
> On Sun, Aug 23, 2015 at 5:35 PM, <richard at rushlogistics.com> wrote:
>
>> I fetch the following rows as follows
>>
>>        my $q = "SELECT ID, NAME, descrip
>>                 FROM accomp_type
>>                 WHERE repair = ?
>>                 ORDER BY NAME";
>>        my $sth = $dbh->prepare($q);
>>        $sth->execute($rep_id);
>>        my $accomp_ref = $sth->fetchall_hashref('ID');
>>
>>        I would like to combine NAME and descrip into NAME so that in my
>> page when
>>        I do:
>>                  <label><input type="checkbox" value="<% Accomp.$ID.ID
>> %>"><% Accomps.$ID.NAME %></label>
>>
>> Name and description will appear instead of the name only. Can anyone
>> tell me how I can accomplish this?
>>
>> Thanks for any help.
>>
>> _______________________________________________
>> Chicago-talk mailing list
>> Chicago-talk at pm.org
>> http://mail.pm.org/mailman/listinfo/chicago-talk
>
>
>
> _______________________________________________
> Chicago-talk mailing list
> Chicago-talk at pm.org
> http://mail.pm.org/mailman/listinfo/chicago-talk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/chicago-talk/attachments/20150826/e5e6b8b4/attachment.html>


More information about the Chicago-talk mailing list