sub print_table {
   my ($squares, $page, $winner, $round, $rounds, $final) = @_;
   my ($visitor, $visitor_name, $time);

   ## print ending table

   print $page->startform(-method=>'POST');

   print_hidden_values($page,$squares,$rounds);

   print ("<input type='hidden' name='round', value='$round'>\n");

   print ("<table border=1 cellpadding=10>\n");
   print ("<tr valign=middle>\n");
   for my $row (0..2) {
     for my $col (0..2) {
        my $cell = $squares->[$row][$col];
        if ($cell eq "") {
          $cell = $final ? "?" 
                : "<td><input type='checkbox' name='choice' value='[$row][$col]'></td>\n";
        }
        print ("<td align=center>" . $cell . "</td>\n");
     }
     print ("</tr><tr valign=middle>\n") unless $row == 2;
   }
   print ("</tr></table><p>\n");

   if ($final) {
     print ("<a href=\"http://soya.serve.com/cgi-bin/tic_tac.cgi\">Play Again!</a>") ;
   } else {
     print $page->submit();
     
     print ("<p><font color='red'>Note: if you pick more than one square, your choice will be the upper and leftmost square that you choose!!</font><p>\n");
   }
   
   print $page->endform();


   print $page->end_html();

   if ($final) {
     #print log of play

     $visitor = $page->remote_host();
     if ($visitor =~ /\d*\.\d*\.\d*\.\d*/) {
       $visitor_name = gethostbyaddr(inet_aton($visitor), AF_INET);
     }

     $time = localtime(time());

     open (MAIL, "| /usr/sbin/sendmail -t");
     print MAIL "To: kclair\@soya.serve.com\n";
     print MAIL "Subject: tic tac toe results\n";
     print MAIL "\n$visitor, $visitor_name: $time: $winner on round $round";
     close MAIL;
   }

}
