Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

using CGI, DBI and HTML::Template (a mini tutorial with example code)

by gav^ (Curate)
on Feb 09, 2002 at 04:13 UTC ( #144315=perlmeditation: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    <form action="color.pl" method="post">
    <p>Your name: <input type="text" name="name" 
    ...
      value="<TMPL_VAR NAME=COLOR>"></p>
    <p><input type="submit"></p>
    </form>
    
  2. or download this
    <p>Hello, <b><TMPL_VAR NAME=NAME></b>. A little
    birdy told me your favorite color is <b><TMPL_VAR NAME=COLOR></b>.
    
  3. or download this
    use CGI;
    use HTML::Template;
    ...
    
    my $t = HTML::Template->new(filename => "$template.tmpl", associate =>
    + $cgi);
    print $t->output;
    
  4. or download this
    use DBI;
    use CGI;
    ...
    
    print $cgi->header;
    print $t->output;
    
  5. or download this
    <table border="1">
    <tr><th>ID</th><th>NAME</th><th>PRICE</th></tr>
    ...
    </TMPL_LOOP>
    
    </table>
    
  6. or download this
    [snip]
    
    ...
    }
    
    $t->param(ROWS => $rows, TOTAL => $sum);
    
  7. or download this
    <table border="1">
    <tr><th>ID</th><th>NAME</th><th>PRICE</th></tr>
    ...
    </table>
    
    <p>The total is <TMPL_VAR NAME=TOTAL></p>
    
  8. or download this
    use DBI;
    use CGI;
    ...
    print $t->output;
    
    $dbh->disconnect;
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://144315]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2022-05-25 19:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (90 votes). Check out past polls.

    Notices?