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

Hi

Please have a look at the following code that will helpful for you.

push @all_user_types, { users_list => $values, users => $values, report_for_user => $values eq $c +gi_user_type }; $html->param(user_types => \@all_user_types );


<TMPL_LOOP NAME="user_types"> <option value="<TMPL_VAR NAME=users>" <TMPL_IF report_for_user>SEL +ECTED</TMPL_IF>><TMPL_VAR NAME=users_list></option> </TMPL_LOOP>
that is the way we used to Build the Elements Using TMPL_LOOP.

If that is Useful for you Please have a look.

"Keep pouring your ideas"

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

Re^2: CGI::Application/HTML::Template problem
by Anonymous Monk on Jan 12, 2006 at 12:34 UTC
    Please have a look at the following code that will helpful for you. 202468746d6c2d3e706172616d28757365725f747970657320203d3e205c40616c6c5f757365725f747970657320293b20 that is the way we used to answer questions.

    If that is Useful for you Please have a look.