I'm trying to print out statistics on a web page, based on an evaluation
form, where the person filling it out answers some questions with values
1-4. These are then stored in a MySQL database. I need to print out
averages for each question, and throw out any zeros (which means they
didn't select an answer for that question). I know I can type out
multiple SELECT statements, but I'm sure it'd be easier to do it with
perl. I'm sure that using an array is the way to go, but after that I'm
lost. Here's what I have so far-
# Sub for averaging all questions for all classes
sub avg_all {
my $dbh = shift;
my $hashref = shift;
my %in = %{hashref};
my $output;
my $sth_avg_all = $dbh->prepare("select round(avg($$answer[0]), 2) from
evaluation where $$answer[0] != 0}"); #this is the statement I need to
repeat with different fields
# output
$output .= "<font face=arial size=+2 color=#008080>Internet Class
Evaluations</font><br><font face=arial size
$output .= "Did this class meet your expectations? $$answer[0]";
}
$sth_avg_all->execute;
--
Kolene