The CGI script for this lab:
- Is called from an HTML page.
- Creates an HTML form which the customer can use to order a book.
- Creates an array and a hash to define a set of books that can be
ordered.
- This list is completely arbitrary and does not use the
real title table at all.
Tasks to Do for this Lab
Modify the CGI script so that rather than using the built-in values, it:
- connects to the Nile database
- reads all the rows from the title table
- uses the ->fetchrow_array method
Solution
Extra for Experts #1
Further modify the CGI script so that the list of books is displayed
in alphabetical order.
Extra for Experts #2
Make the CGI script more efficient by:
- Inserting a call to bind_columns between the calls to prepare
and execute, passing undef as the first argument and references
to the variables which will hold the returned column data.
- Changing the call from fetchrow_array to fetch, and not using
the return value from fetch.
Thus, the calling sequence looks like this:
prepare( <SQL statement> );
bind_columns( undef, (\$col1, \$col2, \$col3) );
execute( );
while ( ->fetch() ) {
do something with $col1, $col2, $col3;
}