forked from titat/project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetQuery4.php
More file actions
21 lines (16 loc) · 851 Bytes
/
getQuery4.php
File metadata and controls
21 lines (16 loc) · 851 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
$conn = new mysqli("127.0.0.1", "root", "", "project_test");
$result = $conn->query("SELECT DepartmentName AS Department,CourseName,COUNT(*) AS NumberofStudent FROM course c JOIN student_course sc ON c.CourseID = sc.CourseID JOIN student s ON sc.AppID = s.AppID JOIN program p ON s.ProgramID = p.ProgramID JOIN department d ON p.DepartmentID = d.DepartmentID GROUP BY c.CourseID,d.DepartmentID ");
$outp = "[";
while($rs = $result->fetch_array(MYSQLI_ASSOC)) {
if ($outp != "[") {$outp .= ",";}
$outp .= '{"Department":"' . $rs["Department"] . '",';
$outp .= '"CourseName":"' . $rs["CourseName"] . '",';
$outp .= '"NumberofStudent":"'. $rs["NumberofStudent"] . '"}';
}
$outp .="]";
$conn->close();
echo($outp);
?>