function tableheader($caption) {
print <<
$caption
| Team1 | Score | Team2 | Score |
TABLE;
}
function connect() {
$user = "";
$password = "";
$db = odbc_connect( 'PHPEG' , $user, $password );
if (!$db) die( "Error in odbc_connect" );
return $db;
}
function report($caption, $comment, $result) {
$count = 0;
// Can ask for number of rows returned, but
// most drivers cannot supply this information
while( odbc_fetch_row( $result) ) {
if($count==0) tableheader($caption); $count++;
$Team1 = odbc_result($result, "Name1");
$Score1 = odbc_result($result, "Score1");
$Team2 = odbc_result($result, "Name2");
$Score2 = odbc_result($result, "Score2");
print "| $Team1 | $Score1 | $Team2 | $Score2 |
";
}
if($count>0) print "
";
else print "$comment
";
}
function runtask($strings) {
list($sqlstring, $caption, $comment) = $strings;
$db = connect();
$result = odbc_exec( $db, $sqlstring);
if (!$result)
die( "Error in odbc_exec( no result returned ) " );
report($caption, $comment, $result);
print "