Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
<?php
include("./layout/header.php");
include (__DIR__."/Utility/surveyData.php");
include (__DIR__."/Utility/dataConnect.php");
include (__DIR__."/Utility/profileData.php");
include (__DIR__."/Utility/hleData.php");
global $db;
$query = "SELECT COUNT(*) AS COUNT FROM MonthlyScore";
$results = $db->getQuery($query);
$numrows = $results[0]['COUNT'];
$rowsperpage = 10;
$totalpages = ceil($numrows / $rowsperpage);
if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) {
$currentpage = (int) $_GET['currentpage'];
} else {
$currentpage = 1;
}
if ($currentpage > $totalpages) {
$currentpage = $totalpages;
}
if ($currentpage < 1) {
$currentpage = 1;
}
$offset = ($currentpage - 1) * $rowsperpage;
//$offset = 0;
$query = "SELECT MemberID, Year, Month, Score FROM MonthlyScore WHERE MONTH = 10 ORDER BY SCORE DESC LIMIT {$offset}, {$rowsperpage}";
$results = $db->getQuery($query);
if($results == true && $results > 0){
$resultKeys = array_column($results, 'MemberID');
$resultValuesScores = array_column($results, 'Score');
}
else{
exit("Error: results array empty");
}
$range = 3;
?>
<body>
<div class="container">
<header class="clearfix">
<h1>Leaderboard</h1>
<nav>
<a href="summary.php" data-info="Summary"><span class = "glyphicon glyphicon-stats"></a>
<a href="leaderboard.php" data-info="Leaderboard"><span class = "glyphicon glyphicon-star"></a>
<a href="profile.php" data-info="Your Profile"><span class = "glyphicon glyphicon-user"></span></a>
</nav>
</header>
<div class="leaderboard flex column wrap">
<div class="leaderboard-table flex column">
<div class="leaderboard-header flex column grow">
<div class="filter-by flex grow wrap">
<div class="time-filter flex grow">
<div class="row-button pointer row-button--active align-center">Last Month</div>
<!-- <div class="row-button pointer align-center">This week</div> -->
</div>
<div class="subject-filter flex grow">
<div class="table-tab pointer flex grow justify-center align-center tab-active">
<svg class="menu-link-icon" fill="#FFFFFF" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
<path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"/>
</svg>
Users</div>
<div class="table-tab pointer flex grow justify-center align-center"> <svg class="menu-link-icon" fill="#4a4a4a" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
<path d="M16 11c1.66 0 2.99-1.34 2.99-3S17.66 5 16 5c-1.66 0-3 1.34-3 3s1.34 3 3 3zm-8 0c1.66 0 2.99-1.34 2.99-3S9.66 5 8 5C6.34 5 5 6.34 5 8s1.34 3 3 3zm0 2c-2.33 0-7 1.17-7 3.5V19h14v-2.5c0-2.33-4.67-3.5-7-3.5zm8 0c-.29 0-.62.02-.97.05 1.16.84 1.97 1.97 1.97 3.45V19h6v-2.5c0-2.33-4.67-3.5-7-3.5z"/>
</svg>
Teams</div>
</div>
</div>
<div class="leaderboard-row flex align-center row--header" style="border-radius: 0 !important;">
<div class="row-position">Rank</div>
<div class="row-user">Name</div>
<div class="row-rank">Score</div>
</div>
</div>
<div class="leaderboard-body flex column grow">
<?php for($i=0;$i<10;$i++) { ?>
<div class="leaderboard-row flex align-center">
<div class="row-position"><?php echo( intval($i+1) + intval($offset) ); ?></div>
<div class="row-user"><?php echo($resultKeys[$i]); ?></div>
<div class="row-rank"><?php echo($resultValuesScores[$i]); ?></div>
</div>
<?php } ?>
</div>
<div class="leaderboard-footer flex align-center">
<div class="pagination">
<?php
if ($currentpage > 1) {
echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=1'><<</a> ";
$prevpage = $currentpage - 1;
echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'><</a> ";
}
for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) {
if (($x > 0) && ($x <= $totalpages)) {
echo " <b><a href='{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a></b> ";
}
}
if ($currentpage != $totalpages) {
$nextpage = $currentpage + 1;
echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'>></a> ";
echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'>>></a> ";
}
?>
</div>
</div>
</div>
</div>
</div>
</div>
</body>