-
Notifications
You must be signed in to change notification settings - Fork 3
/
get_rankings.php
52 lines (44 loc) · 1.45 KB
/
get_rankings.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
<?php
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Content-type: application/json');
require_once 'authorisation.php';
function faidb_connect()
{
$link = mysql_connect('127.0.0.1', 'root', 'ecit5lo5')
or die('Could not connect: ' . mysql_error());
mysql_select_db('fai') or die('Could not select database');
return $link;
}
function ladder_result($name, $dateto, $offset, $limit)
{
$sql = "select LR.*,P.* from tblLadder L, tblLadderResult LR, tblPilot P where L.ladName='$name' and L.ladDateTo='$dateto' and LR.ladPk=L.LadPk and P.pilPk=LR.pilPk order by LR.ldrPosition limit $offset, $limit";
$result = mysql_query($sql) or die('Ladder result query failed: ' . mysql_error());
$results = [];
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$keyrow = [];
$keyrow[] = $row['ldrPosition'];
$keyrow[] = $row['pilLastName'];
$keyrow[] = $row['pilCIVL'];
$keyrow[] = $row['pilNation'];
$keyrow[] = $row['ldrPoints'];
$keyrow[] = $row['ldrSigma'];
$results[]= $keyrow;
}
return $results;
}
$link = faidb_connect();
$name = reqsval('name');
$dateto = reqsval('date');
$offset = reqival('offset');
$limit = reqival('limit');
if ($limit < 1)
{
$limit = 100;
}
$carr = [];
$sorted = ladder_result($name, $dateto, $offset, $limit);
$data = array( 'data' => $sorted );
print json_encode($data);
?>