Exemplo n.º 1
0
    $row = mysql_fetch_object($res);
    return $row;
}
############
# find either a given league (by query param league_id)
# or find the latest league (by created_At)
$league_id = intval($_GET['league_id']);
if ($league_id == 0) {
    $league = get_latest_league();
} else {
    $league = get_league($league_id);
}
$all_leagues = mysql_get_list("select * from leagues order by created_at desc");
$races = mysql_get_list("select * from league_races where league_id=" . $league->id . " order by race_time asc");
# get the current charts
$billboard = mysql_get_list("\nselect \n\td.user_id, d.username, sum(rs.points) as sum_points, count(rs.id) as num_races\nfrom \n\tcf_users d\n\tjoin league_results rs on d.user_id=rs.driver_id\n\tjoin league_races r on rs.race_id=r.id\nwhere\n\tr.league_id={$league->id}\n\tand rs.finished_status = 'Finished Normally'\ngroup by\n\td.user_id\norder by \n\tsum_points desc");
?>
<html>
<head>
  <title>League Results</title>
  <link rel="stylesheet" href="css/blueprint/screen.css" type="text/css" media="screen, projection">
  <link rel="stylesheet" href="css/blueprint/print.css" type="text/css" media="print"> 
  <!--[if lt IE 8]>
    <link rel="stylesheet" href="css/blueprint/ie.css" type="text/css" media="screen, projection">
  <![endif]-->
  <style type="text/css" media="screen">
    table.results {
      border-width: 0px;
      border-style: none;
      border-color: gray;
      border-collapse: collapse;
Exemplo n.º 2
0
function distribute_points($race_id)
{
    global $points;
    $query = sprintf("select * from league_results where race_id=%d and finish_status='Finished Normally' order by position asc", $race_id);
    $results = mysql_get_list($query);
    $ct = 1;
    foreach ($results as $result) {
        $query = sprintf("update league_results set position=%d, points=%d where id=%d", $ct, intval($points[$ct]), $result->id);
        $res = mysql_query($query);
        if (!$res) {
            die("update query {$query} failed: " . mysql_error());
        }
        $ct++;
    }
}
Exemplo n.º 3
0
    while ($row = mysql_fetch_object($res)) {
        array_push($ret, $row);
    }
    return $ret;
}
$seasons = mysql_get_list("select * from seasons order by id desc");
$season = $seasons[0];
$events = mysql_get_list("select * from events where season_id=" . $season->id);
$stats = array();
foreach ($events as $event) {
    # get races for the event
    $races = mysql_get_list("select * from races where event_id=" . $event->id);
    foreach ($races as $race) {
        $results = mysql_get_list("select * from results where finish_status='Finished Normally' and race_id=" . $race->id);
        foreach ($results as $result) {
            $driver = mysql_get_list("select * from drivers where id=" . $result->driver_id);
            $driver = $driver[0];
            if (!$stats[$driver->name]) {
                $stats[$driver->name] = array();
            }
            if ($result->laps_completed >= $race->laps) {
                if ($stats[$driver->name][$event->id]) {
                    if ($stats[$driver->name][$event->id]['race_time'] > $result->race_time) {
                        $stats[$driver->name][$event->id]['result_id'] = $result->id;
                        $stats[$driver->name][$event->id]['race_time'] = $result->race_time;
                        $stats[$driver->name][$event->id]['race_date'] = $race->race_time;
                    }
                    if ($stats[$driver->name][$event->id]['best_lap'] > $result->best_lap) {
                        $stats[$driver->name][$event->id]['best_lap'] = $result->best_lap;
                        $stats[$driver->name][$event->id]['best_date'] = $race->race_time;
                    }