query("SELECT *, ST_AsGeoJSON(geom) as geojson FROM $table WHERE $field = '$value'"); $features = []; foreach($result as $row) { // PHP-Objekt erstellen $geometry = json_decode($row['geojson']); // PHP-Objekt bereinigen unset($row['geom']); unset($row['geojson']); // JSON-Feature hinzufügen $feature = [ "type"=>"Feature", "geometry"=>$geometry, "properties"=>$row ]; array_push($features, $feature); }; // Feature-Collection hinzufügen $featureCollection = [ "type"=>"FeatureCollection", "features"=>$features ]; echo json_encode($featureCollection); // Fehlernachricht ausgeben } catch(PDOException $e) { echo "ERROR ".$e->getMessage(); } ?>