Recent Club Races
“);
print(“
Date | Course | Dist | Type |
---|---|---|---|
” . $RaceDate . “ | ” . $RaceName . “ | ” . $race[“dist”] . ‘ ‘ . $dist_unit . “ | ” . $race[“tag”] . “ |
\n”);
} else if($_GET[‘mode’] == ‘race’ ) {
if (isset($_GET[‘raceid’]))
{
$raceid = sprintf(‘%d’,$_GET[‘raceid’]);
}
else
{
$raceid = 0;
}
// print(“
” . getRaceDesc( $raceid, $dist_unit ) . “
“);
$raceQuery = “SELECT course.dist, course.map, race.conditions ” .
” FROM race, course ” .
” WHERE race.courseid = course.courseid ” .
” AND race.raceid = ” . $raceid;
$result = mysql_query(“$raceQuery”);
if( $row = mysql_fetch_array($result)) {
$courseDist = $row[“dist”];
$conditions = $row[“conditions”];
$map = $row[“map”];
if( $map )
{
print(“
“);
}
if( $conditions )
{
print( ‘‘);
}
} else {
//Error(‘Unknown raceID ‘ . $raceid);
}
//
// SHOW SELECTED RACE’S RESULTS
// (SORT BY DNF TO PUT ALL NON-FINISHERS LAST.)
//
$listquery = “SELECT result.time, ” .
” HOUR(result.time), ” . // [1]
” MINUTE(result.time), ” . // [2]
” SECOND(result.time), ” . // [3]
” rider.id, rider.gender, ” .
” rider.first, rider.last, ” .
” result.dnf, ” .
” race.courseid ” .
” FROM race, result, rider ” .
” WHERE race.raceid = result.raceid ” .
” AND result.riderid = rider.id” .
” AND race.raceid = $raceid ” .
” ORDER BY result.dnf, result.time ASC “;
$result = mysql_query($listquery);
print(“
Place | Name | M/F | Gender Place |
Time | Speed $dist_unit/h |
At | ||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
‘ . $posit++ . “ | ” . $FullName . “ | ‘ . $race[“gender”] . “ | ‘ . $positM++ . “ | ‘ . $positF++ . “ | ” . $TimeLink . “ | ” . $speed . “ | ” . $delta . “ | DNF |
\n”);
if(!$some)
{
print ‘
Results not yet entered. Try again later.
‘;
}
} else if ($_GET[‘mode’] == ‘listriders’ ) {
$where = ”;
//
// PREPARE A WHERE CLAUSE ADDITION
//
//
// FLAG – DO WE NEED TO TEST FOR First OR LAST NAME?
//
$bFirst = 0;
$bLast = 0;
if( isset($_GET[“riderid”]) && $_GET[“riderid”] ) {
$where = sprintf(‘ AND rider.id = %d’, $_GET[“riderid”]);
//
// FIRST AND LAST EFFECTIVELY SET.
//
$bFirst = 1;
$bLast = 1;
} else {
if( isset($_GET[“last”]) && $_GET[“last”] ) {
$bLast = 1;
$where = sprintf(‘ AND rider.last like “%s%%”‘, $_GET[“last”]);
}
if( isset($_GET[“first”]) && $_GET[“first”] ) {
$bFirst = 1;
$whereFirst = sprintf(‘ AND rider.first like “%s%%”‘, $_GET[“first”]);
$where = $where . $whereFirst;
}
}
if( isset($_GET[“year”]) && $_GET[“year”] && $_GET[“year”] != -1 ) {
$whereYear = sprintf(‘ AND YEAR(race.date) = %d’, $_GET[“year”]);
$where = $where . $whereYear;
}
if( isset($_GET[“month”]) && $_GET[“month”] && $_GET[“month”] != -1 ) {
$whereMonth = sprintf(‘ AND month(race.date) = %d’, $_GET[“month”]);
$where = $where . $whereMonth;
}
if( isset($_GET[“courseid”]) && $_GET[“courseid”] && $_GET[“courseid”] != -1 ) {
$whereCourse = sprintf(‘ AND race.courseid = %d’, $_GET[“courseid”]);
$where = $where . $whereCourse;
}
$orderAscDesc = “”;
if( isset($_GET[“sortField”]) && $_GET[“sortField”] ) {
if( isset($_GET[“sortDirection”]) && $_GET[“sortDirection”] ) {
if( $_GET[“sortDirection”] == “DESC” ) {
$orderAscDesc = “DESC”;
} else {
$orderAscDesc = “”;
}
}
$orderby = sprintf(‘ ORDER BY %s %s’, $_GET[“sortField”], $orderAscDesc );
} else {
$orderby = ” ORDER BY race.date DESC “;
}
if( !$bLast && !$bFirst ) {
print ‘
Must enter (partial) first or last name. ‘;
print ‘Try again
‘;
} else {
//
// SHOW SELECTED RACES
//
$listquery = “SELECT race.raceid, race.typeid, tag, race.date, ” .
” location.name, course.dist, course.description, ” .
” result.time, result.dnf, ” .
” rider.first, rider.last “.
” FROM race, sysracetype, course, location, ” .
” result, rider ” .
” WHERE race.courseid = course.courseid ” .
” AND race.typeid = sysracetype.typeid ” .
” AND course.locid = location.locid ” .
” AND race.raceid = result.raceid” .
” AND result.riderid = rider.id” .
$where .
$orderby;
$result = mysql_query($listquery);
print(“
$SortDateLink | Course | Dist | Type | Name | $SortTimeLink |
---|---|---|---|---|---|
” . $RaceDate . “ | ” . $RaceName . “ | ” . $race[“dist”] . ‘ ‘ . $dist_unit . “ | ” . $race[“tag”] . “ | ” . $FullName . “ | ” . $sTime . “ |
\n”);
if(!$some) {
print ‘
No matching results were found.
‘;
}
}
}
function PrepareLinkParams($FieldToSort, $orderAscDesc)
{
//
// LINK HAS ALL ORIGINAL PARAMS.
// BUT SORT ORDER REVERSED (IF IT WAS THERE)
// AND SORT COLUMN SET TO USER CHOSEN COLUMN
//
$params = ”;
foreach( $_GET as $key => $value)
{
if( $key != ‘sortField’ && $key != ‘sortDirection’ )
$params = $params . “$key=$value” . ‘&’;
}
$params = $params . “sortField=$FieldToSort” . ‘&’;
if( $orderAscDesc == “DESC” )
{
$orderAscDesc = “”;
}
else
{
$orderAscDesc = “DESC”;
}
$params = $params . “sortDirection=$orderAscDesc”;
return $params;
}
?>