-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathgetExams.php
More file actions
23 lines (20 loc) · 749 Bytes
/
Copy pathgetExams.php
File metadata and controls
23 lines (20 loc) · 749 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
$curYear = date('Y');
$conn = new mysqli("127.0.0.1", "root", "", "project_test");
$query = "SELECT * FROM subject WHERE ED_year='".$curYear."';";
$result = $conn->query($query);
$outp = "[";
while($rs = $result->fetch_array(MYSQLI_ASSOC)) {
if ($outp != "[") {$outp .= ",";}
$outp .= '{"SubjectID":"' . $rs["SubjectID"] . '",';
$outp .= '"SubjectName":"' . $rs["SubjectName"] . '",';
$outp .= '"ED_year":"'. $rs["ED_year"] . '",';
$outp .= '"Semester":"' . $rs["Semester"] . '",';
$outp .= '"Description":"'. $rs["Description"] . '"}';
}
$outp .="]";
$conn->close();
echo($outp);
?>