#!/usr/bin/perl use strict; use DBI; use CGI qw(:standard); print header(); print start_html("Find Friend"); Query_Database(); print end_html(); sub Query_Database { my $host = ""; my $user = "cs655"; my $password = "abc123"; my $dbname = "cs655"; my $dbh = DBI->connect("dbi:mysql:dbname=$dbname;host=$host", $user, $password); $dbh or die "cannot connect to the database:$!\n"; my $sth = $dbh->prepare ("select * from Friend"); $sth->execute(); while (my $data = $sth->fetchrow_arrayref ()) { Print_Result(@$data); } $sth->finish (); $dbh->disconnect; } sub Print_Result { my ($fname, $lname, $city, $state, $age) = @_; print "First Name: ", $fname, "
"; print "Last Name: ", $lname, "
"; print "City: ", $city, "
"; print "State: ", $state, "
"; print "Age: ", $age, "

"; }