<?php
    error_reporting(E_ALL);
    ini_set('display_errors', 1);

    if(isset($_POST['key'])&&$_POST['key']=="brt6k11t"){    
        require('../connect.php');
    
        $conn = new mysqli($host, $user, $pass, $database);
        $sql = "SELECT `id`,`start_date`, `end_date`, `price` FROM `billings`";
        $billings = mysqli_query($conn, $sql);

        $result = array();

        foreach ($billings as $billing) {
            $result[] = $billing;
        }
    
        mysqli_close($conn);
        
        $response = array("success"=>"yes",
                        "result"=>$result);
        // print_r($result);
    }else{
        $response = array('success' => 'no',
                        'message' => 'Błąd autoryzacji');
    }

    header('Content-Type: application/json');
    echo json_encode($response);
?>