-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathgetQuery5.php
More file actions
24 lines (20 loc) · 1015 Bytes
/
getQuery5.php
File metadata and controls
24 lines (20 loc) · 1015 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
<?php
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
$departID = $_GET['depart'];
$courseID = $_GET['courseID'];
$conn = new mysqli("127.0.0.1", "root", "", "project_test");
$result = $conn->query("SELECT st.StudentID AS STID,fName,lName,p.ProgramName AS Program,d.DepartmentName AS Department FROM student st JOIN student_course sc ON st.AppID = sc.AppID JOIN program p ON st.ProgramID = p.ProgramID JOIN department d ON p.DepartmentID = d.DepartmentID WHERE sc.CourseID = '".$courseID."' AND p.DepartmentID = '".$departID."';");
$outp = "[";
while($rs = $result->fetch_array(MYSQLI_ASSOC)) {
if ($outp != "[") {$outp .= ",";}
$outp .= '{"StudentID":"' . $rs["STID"] . '",';
$outp .= '"fName":"' . $rs["fName"] . '",';
$outp .= '"lName":"' . $rs["lName"] . '",';
$outp .= '"Program":"' . $rs["Program"] . '",';
$outp .= '"Department":"'. $rs["Department"] . '"}';
}
$outp .="]";
$conn->close();
echo($outp);
?>