<?php
require_once "connection.php";
    $sql = "select namaKantor,phoneNumber,alamat,email from KontakPerusahaan";
    if(!$con->query($sql)){
        echo "Error in executing query.";
    }else{
        $result = $con->query($sql);
        if($result->num_rows > 0){
            $return_arr['KontakPerusahaan'] = array();
            while($row = $result->fetch_array()){
                array_push($return_arr['KontakPerusahaan'], array(
                    'namaKantor'=>$row['namaKantor'],
                    'phoneNumber'=>$row['phoneNumber'],
                    'alamat'=>$row['alamat'],
                    'email'=>$row['email'],
                ));
            }
            echo json_encode($return_arr);
        }
}