-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathget_ranks.php
More file actions
39 lines (31 loc) · 831 Bytes
/
Copy pathget_ranks.php
File metadata and controls
39 lines (31 loc) · 831 Bytes
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
<?php
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
include "../../../7klas.cfg";
$conn = new mysqli("localhost", "7klas_app", $db_password, "7klas");
$rnk_yr = "";
if ( isset($_REQUEST["yr"]) && is_numeric($_REQUEST["yr"]) ) {
$rnk_yr = $_REQUEST["yr"];
}
elseif ( isset($argv) && count($argv) > 1 && is_numeric($argv[1]) ) {
$rnk_yr = $argv[1];
}
if ( $rnk_yr != "" ) {
$sql_result = $conn->query("SELECT * FROM ClassRanksJSON WHERE json_obj->\"$.clsYear\" = \"$rnk_yr\";");
}
else {
$sql_result = $conn->query("SELECT * FROM ClassRanksJSON");
}
$json = "";
while($rs = $sql_result->fetch_array(MYSQLI_ASSOC)) {
if ( $json != "" )
{
$json .= ",";
}
$json .= $rs["json_obj"];
}
/* Make array */
$json = "[".$json."]";
$conn->close();
echo $json;
?>