Beispiel #1
0
/**
 * control 
 * 
 * The controlling structure for this script.
 * 
 * @return void
 */
function control()
{
    global $book;
    if (isset($_GET['add'])) {
        displayAddForm();
    } elseif (isset($_POST['addsubmit'])) {
        displayAddSubmit();
    } else {
        displayMain();
    }
}
     } else {
         $id = '';
         //or end here because no one was selected
     }
     readDelete($db, $id);
     break;
 case 'view':
     $id = $_POST['id'];
     view($db, $id);
     break;
 case 'drawAddModal':
     $table_name = $_POST['table_name'];
     $stmt = $db->prepare('SELECT * from ' . $table_name);
     $stmt->execute();
     $records = $stmt->fetchAll();
     displayAddForm($records[0]);
     break;
 case 'update':
     $id = $_POST['id'];
     $user_id = $_POST['user_id'];
     $calories = $_POST['calories'];
     $description = $_POST['description'];
     $activity_type = $_POST['activity_type'];
     $date = $_POST['date'];
     update($db, $id, $user_id, $calories, $description, $activity_type, $date);
     break;
 case 'updateUser':
     //update
     //echo 'inside php update case';
     if (isset($_POST['id']) && !empty($_POST['id'])) {
         $id = $_POST['id'];