-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprogram.php
More file actions
83 lines (49 loc) · 2.02 KB
/
program.php
File metadata and controls
83 lines (49 loc) · 2.02 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
include("cbumobileConnection.php");
$schoolname=urldecode($_GET['schoolName']);
$schoolName=filter_var($schoolname, FILTER_SANITIZE_STRING);
$getSchoolId="SELECT SchoolCode
FROM school
WHERE SchoolName='$schoolName'
";
$getIdResponse=mysqli_query($connection, $getSchoolId);
if(isset($getIdResponse)){
while($row=mysqli_fetch_assoc($getIdResponse)){
$schoolId=$row['SchoolCode'];
}#while loop for getting school id
if(isset($schoolId)){
$getPrograms="SELECT ProgramName, Duration, Fees, Certificate
FROM program
WHERE SchoolId='$schoolId'
";
$response=mysqli_query($connection, $getPrograms);
if(isset($response)){
while($row=mysqli_fetch_assoc($response)){
$program[]=$row;
}
if(!empty($program)){
echo json_encode($program);
}else{
$status="Fail";
$message="programs for that for school of ".$schoolName." not yet included.";
printError($status,$message);
}#checking if the array is empty or null
}else{
$status="Fail";
$message="Unable to get programs.";
printError($status,$message);
}#program get else statement
}#Schoolid set check if statement
}else{
$status="Fail";
$message="Unable to get school ID.";
printError($status,$message);
}#main if statements
function printError($status,$message){
$fail["Status"]=$status;
$fail["Message"]=$message;
$failure[]=$fail;
echo json_encode($failure);
}
mysqli_close($connection);
?>