Month Top Scores
| # |
Username |
Points |
prepare("SELECT username, sum(points_made) as points FROM triviauserlog WHERE year=:year AND month=:month GROUP BY username ORDER BY points DESC LIMIT 10");
$q->execute(array('year'=>$year, 'month'=>$month));
if ($q === false) {
die("Error: database error: table does not exist\n");
} else {
$result = $q->fetchAll();
foreach($result as $key=>$res) {
echo '';
echo '| ' . ($key+1) . ' | ';
echo '' . $res['username'] . ' | ';
echo '' . $res['points'] . ' | ';
echo '
';
}
}
} else {
die($err);
}
?>
Year Top Scores
| # |
Username |
Points |
prepare("SELECT username, sum(points_made) as points FROM triviauserlog WHERE year=:year GROUP BY username ORDER BY points DESC LIMIT 10");
$q->execute(array('year'=>$year));
if ($q === false) {
die("Error: database error: table does not exist\n");
} else {
$result = $q->fetchAll();
foreach($result as $key=>$res) {
echo '';
echo '| ' . ($key+1) . ' | ';
echo '' . $res['username'] . ' | ';
echo '' . $res['points'] . ' | ';
echo '
';
}
}
} else {
die($err);
}
?>
sub($interval);
$interval = new DateInterval('P1D');
for($i=0;$i<7;$i++) {
if($i>0) {
$sqlClause .= ' or ';
}
$sqlClause .= '(day=' . $week->format('j') .
' and month=' . $week->format('n') .
' and year=' . $week->format('Y') .
')';
$week->add($interval);
}
?>
Week Top Scores
| # |
Username |
Points |
query("SELECT username, sum(points_made) as points FROM triviauserlog WHERE $sqlClause GROUP BY username ORDER BY points DESC LIMIT 10");
if ($q === false) {
die("Error: database error: table does not exist\n");
} else {
$result = $q->fetchAll();
foreach($result as $key=>$res) {
echo '';
echo '| ' . ($key+1) . ' | ';
echo '' . $res['username'] . ' | ';
echo '' . $res['points'] . ' | ';
echo '
';
}
}
} else {
die($err);
}
?>