diff --git a/html/api/Models/WorkoutType.php b/html/api/Models/WorkoutType.php new file mode 100644 index 0000000..4af5091 --- /dev/null +++ b/html/api/Models/WorkoutType.php @@ -0,0 +1,22 @@ +id = $id; + $this->name = $name; + $this->description = $description; + $this->type = $type; + $this->unit = $unit; + } + +} \ No newline at end of file diff --git a/html/api/exercises.php b/html/api/exercises.php new file mode 100644 index 0000000..57391f5 --- /dev/null +++ b/html/api/exercises.php @@ -0,0 +1,37 @@ +prepare($sql); + $stmt->bindParam(1, $_GET['token']); + if ($stmt->execute()){ + if ($stmt->rowCount() == 1){ + $userData = $stmt->fetchAll(PDO::FETCH_ASSOC); + $username = $userData[0]['username']; + $userID = $userData[0]['user']; + $sql = "select workout_types.id, name, description, type, unit from workout_types inner join workout_type_measurements on workout_types.measurement=workout_type_measurements.id "; + $stmt = $pdo->prepare($sql); + $stmt->bindParam(1, $userID); + if ($stmt->execute()){ + $workoutTypes = $stmt->fetchAll(PDO::FETCH_ASSOC); + $returnTypes = array(); + foreach ($workoutTypes as $workoutType){ + $returnTypes[] = new WorkoutType($workoutType['id'], $workoutType['name'], $workoutType['description'], $workoutType['unit'], $workoutType['unit']); + } + header('Content-Type: application/json'); + echo json_encode($workoutTypes); + } + }else{ + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + } + }else{ + var_dump($stmt->errorInfo()); + } + + //header('Content-Type: application/json'); +}else{ + + +} \ No newline at end of file