query($sql); if ($result != null) { while($row = $result->fetch_assoc()){ $json[] = $row; } $data['data'] = $json; $result = mysqli_query($mysqli,$sql); echo json_encode($data); } else echo "keine Daten empfangen!"; ?>