<?php
include('database_connection.txt');
header("Content-Type: application/json; charset=utf-8");

    $conn = mysqli_connect($host, $user, $password, $db);
    
    if(!$conn){
        http_response_code(500);
        echo json_encode(["error" => "Database connection failed: " . mysqli_connect_error()]);
        exit;
    }

    $result = $conn->query("select * from person_summary");
    $rows = [];

    while($row = $result->fetch_assoc()){
        $rows[] = $row;
    }

    echo json_encode($rows);
    $conn->close();

    /*
    $query = "select * from person_summary";
    $result = mysqli_query($conn, $query) or die("query has failed");
    */

?>