Tour 2007 results

$tour="2007";
echo "Here are all the results available from our Tour $tour:

";

function LinkToFile($path, $base, $name, $text, $pre, $post)
{
if (file_exists($path.$base.$name))
return "$pre$text$post";
else
return "";
}

$path = "/var/www/html/drupal47";
$base = "/sites/new.pwca.org/results/$tour/";

$mytable = array();

// Title
$myheader = array("",t("Task results"),t("Competition"),t("World-Cup"));

for ($task=1;$task {
// get the competition code letter (A B C...)
$task_comp = db_result(db_query( "SELECT COMP from SX_SCORES where YEAR = $tour and TASK = $task LIMIT 1"));
// get the competition name
$comp_name = db_result(db_query("SELECT COMP_NAME from SX_COMPS where YEAR='$tour' and COMP_CODE='$task_comp'"));

if (LinkToFile($path, $base, "T".$task."O.pdf", " Overall","","")!="") $mytable[] = array("Task $task ($comp_name)
". LinkToFile($path, $base, "T".$task.".kml", " KML","","").LinkToFile($path, $base, "T".$task.".kmz", " KML","",""),LinkToFile($path, $base, "T".$task."O.pdf", " Task $task Overall","","
")." ".LinkToFile($path, $base, "T".$task."W.pdf", " Task $task Women","","
")." ". LinkToFile($path, $base, "T".$task."N.pdf", " Task $task Nations","","
")." ".LinkToFile($path, $base, "T".$task."T.pdf", " Task $task Teams","",""), LinkToFile($path, $base, "C$task_comp"."O".$task.".pdf", " Competition Overall","","
")." ". LinkToFile($path, $base, "C$task_comp"."W".$task.".pdf", " Competition Women","","
")." ". LinkToFile($path, $base, "C$task_comp"."N".$task.".pdf", " Competition Nations","","
")." ". LinkToFile($path, $base, "C$task_comp"."T".$task.".pdf", " Competition Teams","",""), LinkToFile($path, $base, "WCO".$task.".pdf", " World-Cup Overall","","
")." ". LinkToFile($path, $base, "WCW".$task.".pdf", " World-Cup Women","","
")." ". LinkToFile($path, $base, "WCN".$task.".pdf", " World-Cup Nations","","
")." ". LinkToFile($path, $base, "WCT".$task.".pdf", " World-Cup Teams","",""));
}

echo theme_table($myheader, $mytable);
?>