Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re^3: CGI::Application/HTML::Template problem

by mbadolato (Hermit)
on Jan 12, 2006 at 08:05 UTC ( #522637=note: print w/replies, xml ) Need Help??

in reply to Re^2: CGI::Application/HTML::Template problem
in thread CGI::Application/HTML::Template problem

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') ));

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://522637]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (1)
As of 2023-06-06 19:24 GMT
Find Nodes?
    Voting Booth?
    How often do you go to conferences?

    Results (29 votes). Check out past polls.