-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathrank.php
More file actions
executable file
·92 lines (79 loc) · 2.31 KB
/
rank.php
File metadata and controls
executable file
·92 lines (79 loc) · 2.31 KB
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
<?php
session_start();
include('settings.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Online Judge</title>
<meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" />
<link rel="stylesheet" type="text/css" media="screen" href="css/screen.css" />
<script type="text/javascript" src="jquery.js"></script>
</head>
<body class="rank">
<!-- wrap starts here -->
<div id="wrap">
<?php include('header.php'); ?>
<div id="content-outer" class="clear">
<div id="left">
<div class="entry">
<?php
if(!isset($_GET['contestID'])){
echo '
<h2>Overall Rankings</h2>
<table border="1" width="100%" >
<tr>
<th>Rank</th><th>Username</th><th>Score</th>
</tr>';
$cn = mysql_connect('localhost', $DBUSER, $DBPASS);
mysql_select_db($DBNAME, $cn);
$query = "select username,score from `users` order by score DESC , penalty ASC";
$logged = mysql_query($query);
for($i=0;$logg = mysql_fetch_array($logged);$i++){
echo "
<tr ".($i%2==0?"class= 'altrow'":"").">
<td > ".($i+1)."</td> <td ><a href='profile.php?username=".$logg['username']."'>".$logg['username']."</a></td>
<td>".$logg['score']."</td>
</tr>";
}
mysql_close($cn);
}
else{
$contestID=intval($_GET['contestID']);
$cn = mysql_connect('localhost', $DBUSER, $DBPASS);
mysql_select_db($DBNAME, $cn);
$query = "select Name from `contests` where contestID=$contestID ";
$logged = mysql_query($query);
$logg = mysql_fetch_array($logged);
if(isset($logg['Name'])){
echo '
<h2>Rankings for '.$logg['Name'].'</h2>
<table border="1" width="100%" >
<tr>
<th>Rank</th><th>Username</th><th>Score</th>
</tr>';
}
else{
echo 'Not available';
}
$query = "select username,score from `contest_$contestID` order by score DESC ,penalty ASC ";
$logged = mysql_query($query);
for($i=0;$logg = mysql_fetch_array($logged);$i++){
echo "
<tr ".($i%2==0?"class= 'altrow'":"").">
<td > ".($i+1)."</td> <td ><a href='profile.php?username=".$logg['username']."'>".$logg['username']."</a></td>
<td>".$logg['score']."</td>
</tr>";
}
mysql_close($cn);
}
?>
</table>
</div>
</div>
<?php include("sidebar.php"); ?>
</div>
</div>
</body>
<?php include("footer.php"); ?>
</html>