function get_all_trains_at_stop($stop) { $stmt = $this->mysqli->prepare($this->getAllTrainsSql); $stmt->bind_param('s', $stop); $stmt->execute(); $stmt->bind_result($next_time); $trains = array(); while ($stmt->fetch()) { $trains[] = $next_time; } $stmt->close(); return $trains; } } if (isset($_GET['stop'])) { echo json_encode(array("next_time" => $metro->get_next_train($_GET['stop'], $_GET['time']), "all_trains" => $metro->get_all_trains_at_stop($_GET['stop']))); } if (isset($_POST['username'])) { if ($_POST['username'] != '') { echo json_encode($user->login($_POST['username'])); } } if (isset($_POST['register'])) { echo json_encode($user->register($_POST['register'], $_POST['favorite_stop'])); } if (isset($_POST['action']) && $_POST['action'] == 'logout') { echo json_encode($user->logout()); } if (isset($_GET['all_trains'])) { echo json_encode($metro->get_all_trains_at_stop($_GET['all_trains'])); }