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

I'm not sure what this has to do with my code...did i miss something? I see no reference to my own code, nor any way to properly coerce the query string data into my template...
meh.
  • Comment on Re^2: CGI::Application/HTML::Template problem

Replies are listed 'Best First'.
Re^3: CGI::Application/HTML::Template problem
by mbadolato (Hermit) on Jan 12, 2006 at 08:05 UTC
    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') ));