Still dosen't show, I cannot understand it.
This is the code...the hidden tag is shown in bold
Code:
#!perl
use Win32::ODBC;
use CGI;
my($db) = new Win32::ODBC("Exam");
my($db2) = new Win32::ODBC("Exam");
my($q) = new CGI;
$db->Sql("SELECT * FROM questions ORDER BY questions.question;");
print_header();
create_questions();
print_footer();
# subroutines
sub print_header {
print $q->header(),
$q->start_html(-title=>'Exam test', -style=>{'src'=>'/style2.css'}),
$q->h1('Products'),
$q->br;
}
sub print_footer {
print $q->br,
$q->submit(-value=>'Submit'),
$q->reset(-value=>'Reset'),
$q->end_html();
}
sub create_questions {
$q->startform(-action=>'exam_test2.pl');
$j = 1;
while($db->FetchRow()) {
%data = $db->DataHash();
print "Ques $data{'questionID'}: $data{'question'} ";
$db2->Sql("SELECT questions.questionID, answers.answer, answers.correct FROM questions INNER JOIN answers ON questions.questionID = answers.questionID WHERE (((questions.questionID)=$data{'questionID'}));");
@answers = ();
$i = 0; # hold the element position in the answers list
while($db2->FetchRow()) {
%data = $db2->DataHash();
@answers[$i] = ($data{'answer'}); # push the answer into a list
$i++; # increment i to move forward one element in the list
}
$radioName = "answer" . $j;
print $q->radio_group(-name=>$radioName,
-values=>[@answers]);
print $q->br;
$j++;
}
$q->hidden(-name=>'numQuestions',-value=>$j);
$q->endform(); # print a closing HTML </form> tag
$db->Close(); # close the connection to the ODBC
Any ideas please? Thanks in advance!
Bookmarks