table 1: vote_count elements: current_vote (a counter, to identify which data to use) table 2: vote_misc elements: vote_no (used as an ID, to search for the data for a specific poll number) description (the descriptive text above the form) begun_by (the user who begun the poll) date_begun (the date the poll started) date_ended (the date the poll concluded) table 3: vote_text elements: vote_no (as for vote_misc) option_1 (text for the option number) (through to) option_6 (text for the option number) table 4: vote_numbers elements: vote_no (as for vote_misc) option_1 (numbers for the option number) (through to) option_6 (numbers for the option number) #### ## Read the current vote number from the mySQL database. my $dbh = DBI->connect("DBI:mysql:$database","$username","$password") || error_fatal ("[ vote.cgi: Admin: Unable to open mySQL database - $! ]"); my $sth_1 = $dbh->prepare("SELECT current_vote FROM vote_count"); $sth_1->execute(); my @vote_no = $sth_1->fetchrow_array; $sth_1->finish(); my $current_vote = $vote_no[0]; # Subroutines. ## Form printing subroutine. sub print_form { ### Read the data from the mySQL database. my $dbh = DBI->connect("DBI:mysql:$database","$username","$password") || error_fatal ("[ vote.cgi: Admin: Unable to open mySQL database - $! ]"); my $sth_2 = $dbh->prepare("SELECT description FROM vote_misc WHERE vote_no='$current_vote'"); $sth_2->execute(); my $description = $sth_2->fetchrow_array(); $sth_2->finish(); my $sth_3 = $dbh->prepare("SELECT option_1,option_2,option_3,option_4,option_5,option_6 FROM vote_text WHERE vote_no='$current_vote'"); $sth_3->execute(); my @options = $sth_3->fetchrow_array(); $sth_3->finish(); ### Print the submission form using the values gathered from the mySQL database. print "Content-type: text/html\n\n"; print "\n"; ### Heading. print "
\n"; print "\n\n"; print "Vote\n"; print "\n\n"; ### Description. print "\n\n"; print "$description\n"; print "\n\n"; ### Option 1. print "\n\n"; print "\n"; print "      $options[1]\n"; print "\n\n"; ### Option 2. print "\n\n"; print "\n"; print "      $options[2]\n"; print "\n\n"; ### Option 3. print "\n\n"; print "\n"; print "      $options[3]\n"; print "\n\n"; ### Option 4. print "\n\n"; print "\n"; print "      $options[4]\n"; print "\n\n"; ### Option 5. print "\n\n"; print "\n"; print "      $options[5]\n"; print "\n\n"; ### Option 6. print "\n\n"; print "\n"; print "      $options[6]\n"; print "\n\n"; ### Submit button. print "\n\n"; print "\n"; print "     \n"; print "\n\n"; ### Ender. print "\n"; print "
\n"; print ""; exit; }