Example #1
0
    $insert = false;
}
if (isset($_POST['newID'])) {
    $newID = $_POST['newID'];
    $insert = true;
} else {
    $insert = false;
}
if ($insert == true) {
    // echo "insert";
    $e = edit_subject($oldID, $newName, $newCoord, $newID);
    echo $e;
}
//Delete subject
if (isset($_POST['deleteID'])) {
    delete_subject($_POST['deleteID']);
}
##Questions code:
//Get topic list from subjects:
if (isset($_POST['subjID'])) {
    //Get the subjects and echo them so we can grab the DATA
    $topics = showTopics($_POST['subjID']);
    echo json_encode($topics);
}
//Show questions if the topic ID has been set
if (isset($_POST['topicID'])) {
    $questions = showQuestions($_POST['topicID']);
    echo json_encode($questions);
}
//Insert question if a request has been made
if (isset($_POST['addQ'])) {
 protected function delete()
 {
     global $db;
     $params = array();
     if ($this->method == "POST") {
         if (sizeof($this->args) == 2) {
             $type = $this->args[0];
             $main_arg = $this->args[1];
             if (is_numeric($main_arg)) {
                 if ($type == "subject") {
                     $params["sid"] = $main_arg;
                     return delete_subject($db, $params);
                 } else {
                     if ($type == "topic") {
                         $params["tid"] = $main_arg;
                         return delete_topic($db, $params);
                     } else {
                         if ($type == "section") {
                             $params["section_id"] = $main_arg;
                             return delete_section($db, $params);
                         } else {
                             if ($type == "example") {
                                 $params["eid"] = $main_arg;
                                 return delete_example($db, $params);
                             } else {
                                 return "No such object exists in the database!";
                             }
                         }
                     }
                 }
             } else {
                 return "The associated id needs to be a numerical value!";
             }
         } else {
             return "This requires two parameters: the object type and associated id!";
         }
     } else {
         return "This only accepts POST requests!";
     }
 }