Chapter 2 Lab
A CGI Script that Connects to a Database and Dumps One of Its Tables
Files You Need for this Lab
Tasks to Do for this Lab
- Modify the form so that it asks for the name of a database rather
than the name of a file.
- Combine the CGI script and perl program so that the CGI script
connects to the database specified by the modified form and
dumps the contents of the table named "title".
- Change the form's ACTION attribute so that it
calls your edited CGI script.
- Ensure that each row of the table is displayed on a separate line
of the browser.
(Hint: use the <PRE> tag or CGI.pm's
- Use the do method instead of
the three-step prepare/execute/finish sequence, e.g.
$rv = $dbh->do( "SQL STATEMENT" );
- Returns only a return value, not a statement handle.
- Not available in all DBD implementations.
Extra for Experts
- Make the output look better by drawing a box around it.
- Hint: put it in a bordered table.
- Source code
- Run it
Dan Keller Technical Services © 2000