prepare("SELECT Offence_ID, Offence_description, Offence_maxFine FROM Offence"); $stmt->execute(); $result = $stmt->fetchAll(PDO::FETCH_ASSOC); echo json_encode(array("message" => "ok", "offences" => $result)); } else { echo json_encode(array("message" => "Not logged in ")); }