-
Notifications
You must be signed in to change notification settings - Fork 0
/
leaderboard.php
105 lines (92 loc) · 2.34 KB
/
leaderboard.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
require_once 'db.php';
require_once 'library.php';
session_start();
?>
<html>
<head>
<title> Fantasy Politics </title>
<link rel="SHORTCUT ICON" href="images/icon.jpg"/>
<link rel="stylesheet" type="text/css" href="stylesheets/menu_bar.css"/>
<link rel="stylesheet" type="text/css" href="stylesheets/leaderboard.css"/>
<link rel="stylesheet" type="text/css" href="stylesheets/global.css"/>
</head>
<body background="images/flag.jpg">
<script>
var el = document.getElementsByTagName("body")[0];
el.className = "";
</script>
<div id="top">
<div class="inner">
<div id="logo">
<h3> chooseyourchief.com </h3>
</div>
<nav id="navbar">
<?php require_once 'navbar.php'; ?>
</nav>
</div>
</div>
<div id="main">
<h1>LEADERBOARD</h1> <br/>
<?php
$query = "SELECT SUM(B.DELEGATES) AS SCORE, A.EMAIL AS EMAIL
FROM user_selections AS A JOIN results AS B
ON A.state = B.state
WHERE A.candidate = B.candidate
GROUP BY A.EMAIL
ORDER BY SCORE DESC, A.EMAIL DESC
LIMIT 25";
$result = mysql_query($query) or die ('bad query');
if (count($result)==0){exit();}
echo "<table>
<tr>
<th>Rank</th>
<th>User</th>
<th>Score</th>
</tr> \n";
$count=0;
$currentscore=-1;
$currentrank=0;
while($row = mysql_fetch_array($result))
{
$count++;
$email = $row['EMAIL'];
$score = $row['SCORE'];
if($currentscore<>$row['SCORE'])
{$currentrank = $count;}
$currentscore=$row['SCORE'];
$username = getusername($email);
if ($count%2 == 0)
{echo "<tr>" . "\n";}
else {echo "<tr class='alt'>" . "\n";}
echo "<td>" . $currentrank . "</td>" . "\n";
echo "<td>" . $username . "</td>" . "\n";
echo "<td>" . $score . "</td>" . "\n";
echo "</tr>" . "\n";
}
echo "\n </table>" . "\n";
?>
</div>
<script src="javascript/jquery.js"></script>
<script src="javascript/modernizr.js"></script>
<script>
(function($){
var nav = $("#navbar");
nav.find("li").each(function() {
if ($(this).find("ul").length > 0) {
$("<span>").text("^").appendTo($(this).children(":first"));
$(this).mouseenter(function(){
$(this).find("ul").stop(true, true).slideDown(70);
});
$(this).mouseleave(function(){
$(this).find("ul").stop(true, true).slideUp(200);
});
}
});
})(jQuery);
</script>
</body>
</html>
<?php
mysql_close($db);
?>