function showCompetitionResults($resultsTable = 'Results')
{
    #----------------------------------------------------------------------
    global $chosenCompetitionId;
    global $chosenByPerson, $chosenAllResults, $chosenTop3, $chosenWinners;
    #--- Get the results.
    $competitionResults = getCompetitionResults($resultsTable);
    startTimer();
    tableBegin('results', 8);
    if ($chosenWinners) {
        tableHeader(explode('|', 'Event|Person|Best||Average||Citizen of|Result Details'), array(2 => 'class="R"', 4 => 'class="R"', 7 => 'class="f"'));
    }
    if ($chosenTop3) {
        tableHeader(explode('|', 'Place|Person|Best||Average||Citizen of|Result Details'), array(0 => 'class="r"', 2 => 'class="R"', 4 => 'class="R"', 7 => 'class="f"'));
    }
    foreach ($competitionResults as $result) {
        extract($result);
        $isNewEvent = !isset($previousEventId) || $eventId != $previousEventId;
        $isNewRound = !isset($previousRoundId) || $roundId != $previousRoundId;
        #--- Welcome new events.
        $winnerEvent = '';
        if ($isNewEvent) {
            $internalEventHref = "c.php?i={$chosenCompetitionId}&allResults=1#{$eventId}";
            if ($chosenTop3) {
                tableCaption(false, internalEventLink($internalEventHref, $eventName));
            }
            if ($chosenWinners) {
                $winnerEvent = internalEventLink($internalEventHref, $eventCellName);
            }
            if ($chosenAllResults && isset($previousEventId)) {
                // tableRowBlank();
                tableRowBlank();
            }
        }
        #--- Welcome new rounds.
        if ($chosenAllResults && ($isNewEvent || $isNewRound)) {
            $anchors = ($isNewEvent ? "{$eventId} e{$eventId} " : "") . "e{$eventId}_{$roundId}";
            $eventHtml = eventLink($eventId, $eventName);
            $caption = spaced(array($eventHtml, $roundName, $formatName, "<a href='#e{$eventId}_{$roundId}'>link</a>"));
            tableCaptionNew(false, $anchors, $caption);
            $bo3_as_mo3 = $formatId == '3' && ($eventId == '333bf' || $eventId == '333fm' || $eventId == '333ft');
            $headerAverage = $formatId == 'a' || $formatId == 'm' || $bo3_as_mo3 ? 'Average' : '';
            $headerAllResults = $formatId != '1' ? 'Result Details' : '';
            tableHeader(explode('|', "Place|Person|Best||{$headerAverage}||Citizen of|{$headerAllResults}"), array(0 => 'class="r"', 2 => 'class="R"', 4 => 'class="R"', 7 => 'class="f"'));
        }
        #--- One result row.
        tableRow(array($chosenWinners ? $winnerEvent : $pos, personLink($personId, $personName), formatValue($best, $valueFormat), $regionalSingleRecord, formatValue($average, $valueFormat), $regionalAverageRecord, $countryName, formatAverageSources($formatId != '1', $result, $valueFormat)));
        $previousEventId = $eventId;
        $previousRoundId = $roundId;
    }
    tableEnd();
    stopTimer("printing the huge table");
}
function showCurrentPersonalRecords()
{
    #----------------------------------------------------------------------
    global $chosenPersonId;
    $bests = dbQuery("\n\n  SELECT * FROM\n\n   (SELECT \n      eventId,\n      best single,\n      worldRank singleRank,\n      continentRank singleRankContinent,\n      countryRank singleRankCountry\n    FROM RanksSingle\n    WHERE personId='{$chosenPersonId}') singles\n    \n    LEFT JOIN\n   \n   (SELECT \n      eventId eC,\n      best average,\n      worldRank averageRank,\n      continentRank averageRankContinent,\n      countryRank averageRankCountry\n    FROM RanksAverage\n    WHERE personId='{$chosenPersonId}') average\n    \n    ON eventId = eC,\n    Events event\n    WHERE\n      eventId = event.id\n    ORDER BY\n      event.rank\n\n\n  ");
    tableBegin('results', 10);
    tableCaption(false, "Current Personal Records");
    tableHeader(explode(" ", "Event NR CR WR Single Average WR CR NR "), array("", "class='r'", "class='r'", "class='R'", "class='R2'", "class='R2'", "class='R'", "class='r'", "class='r'", "class='f'"));
    $oddMessage = "A missing or worse country/continent rank compared to a larger region rank is due to the change of country because results from previous regions don&#39;t count for differing current regions.";
    foreach ($bests as $best) {
        extract($best);
        $odd = $singleRankCountry > $singleRankContinent || $singleRankContinent > $singleRank || $averageRankCountry > $averageRankContinent || $averageRankContinent > $averageRank || !$singleRankCountry && $singleRankContinent || !$singleRankContinent && $singleRank || !$averageRankCountry && $averageRankContinent || !$averageRankContinent && $averageRank;
        tableRow(array(internalEventLink("#{$eventId}", eventCellName($eventId)), "<span style='color:#999'>" . colorMe($singleRankCountry) . "</span>", colorMe($singleRankContinent), colorMe($singleRank), eventLink($eventId, formatValue($single, valueFormat($eventId))), eventAverageLink($eventId, formatValue($average, valueFormat($eventId))), colorMe($averageRank), colorMe($averageRankContinent), "<span style='color:#999'>" . colorMe($averageRankCountry) . "</span>", $odd ? "<a title='{$oddMessage}' style='color:#66F' onclick='alert(\"{$oddMessage}\")'>(*)</a>" : ''));
    }
    tableEnd();
}