Ejemplo n.º 1
0
     } else {
         if ($tag == "getStudentInfo") {
             $student_no = $_GET['student_no'];
             $result = $db->getStudentById($student_no);
             if ($result != false) {
                 $res["error"] = FALSE;
                 $res['result'] = $result;
                 echo json_encode($res);
             } else {
                 $res["error"] = TRUE;
                 $res["error_msg"] = "Failed to retrieve student details";
                 echo json_encode($res);
             }
         } else {
             if ($tag == "getStudents") {
                 $result = $db->getStudents();
                 if ($result != false) {
                     $res['error'] = false;
                     $res['result'] = $result;
                     echo json_encode($res);
                 }
             } else {
                 $response["error"] = TRUE;
                 $response["error_msg"] = "Unknown tag. Use a proper tag";
                 echo json_encode($response);
             }
         }
     }
 } else {
     $response["error"] = TRUE;
     $response["error_msg"] = "Required parameter 'tag' is missing!";