An error har occured.
', $e->getMessage(), '
'; } $sth = $dbh->query("SELECT * FROM Category"); $sth->setFetchMode(PDO::FETCH_ASSOC); $result = $sth->fetchAll(); if (count($result) > 0) { echo json_encode($result); // foreach($result as $r) { // $data[] = [] // echo $r['name'].",".$r['id'].PHP_EOL; // } }