sub print_response { unless ($query->param) { print "No data has been submitted"; return; } $sql = "SELECT col1, col2 FROM test ORDER BY col2 desc;"; $sth=$dbh->prepare($sql) or die $dbh->errstr; $sth->execute; print ""; print ""; print ""; print ""; print ""; print ""; while (my $hash_ref = $sth->fetchrow_hashref) { $the_st = $hash_ref->{'col1'}; $the_mc = $hash_ref->{'col2'}; print ""; } print "
col1col2
$the_st$the_mc
"; $sth->finish; }