#!/usr/local/bin/perl ######################################################################### #Search for ice cream orders - using database ######################################################################### use CGI "param"; use DBI; @searchFlavor = param('ice'); $dbh = DBI->connect("DBI:mysql:demo","demo","demo"); #$dbh = DBI->connect("DBI:mysql:demo:db.it.scps.nyu.edu:3300","demo","demo"); print "Content-type: text/html \n"; print "\n"; print " Search for orders

Result for search:

"; $sql = "select * from ice_orders "; $sql .= "where flavor = \'$searchFlavor[0]\' "; $cursor = $dbh->prepare($sql); $rc = $cursor->execute(); while( @columns = $cursor->fetchrow_array() ) { ($id,$fname,$address,$flavor) = @columns; print ""; } print "
NameAddressIce Cream Flavor
$fname $address $flavor
"; $dbh->disconnect(); exit(0);