prepare("SELECT Vehicle_type, People_name, Incident_Date, Incident_Report, Offence_description FROM Incident INNER JOIN People P on Incident.People_ID = P.People_ID INNER JOIN Vehicle V on Incident.Vehicle_ID = V.Vehicle_ID INNER JOIN Offence O on Incident.Offence_ID = O.Offence_ID;"); $stmt->execute(); $result = $stmt->fetchAll(PDO::FETCH_ASSOC); echo json_encode(array("message" => "ok", "data" => $result)); } else { echo json_encode(array("message" => "Not logged in ")); }