#!/usr/bin/perl -wT #################################### #Name: PerlMysql_1.cgi #Lesson 1 in Perl DBI using Mysql. # Database server: MySQL # Table in use: from (Student.csv and FullTimeStudent.csv) # Author: Jen Chen # Date: 05/17/04 #################################### use CGI ":standard"; #Call the perl CGI library. use DBI; #Call the Perl DBI library. print header(); #Need this line; otherwise print the html header and teh contents type. print "Testing Perl CGI\n"; print "\n"; print "

Welcome to CS 345 Perl CGI

"; print "

"; my $dbh = DBI->connect("DBI:mysql:dbname=XXXXXXXX","XXXXXXXX","") || die "Error connecting to DB: '$DBI::errstr'"; my $sth = $dbh->prepare("SELECT Stno, SName, Major, Class, BDate FROM XXXXXXXX where Major='COSC'"); print ""; print ""; $sth->execute(); $index = 1; while(($stno,$sname,$major,$class,$bdate) = $sth->fetchrow_array()){ print ""; $index++; } $sth->finish(); print "
OrderStudent #NameMajorClassBirth Date
$index$stno$sname$major$class$bdate
"; $dbh->disconnect(); print "";