Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
You have

$tmpl->param( product => $self->dbh->selectall_arrayref(q[SELECT image, price, description, serial FROM product WHERE id=?], { Slice => {} }, $q->param('item') ));

You're selecting image, price, description and serial from the data, and those are going into the products loop as named elements, with their values as was selected.

The problem is, you're using $q->param('item') for your id, but since you're not including that as one of the values that will be available from the SQL, it isn't available for the product loop to use. CGI parameters are not automatically available to templates (though you can easily add them, though I forget the syntax off the top of my head... sorry it's 1am and I don't feel like looking it up).

Something like this will work as well

$tmpl->param( product => $self->dbh->selectall_arrayref(q[SELECT id as "item", image, price, description, serial FROM product WHERE id=?], { Slice => {} }, $q->param('item') ));


In reply to Re^3: CGI::Application/HTML::Template problem by mbadolato
in thread CGI::Application/HTML::Template problem by stonecolddevin

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (1)
As of 2024-04-18 23:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found