<?php
ini_set('display_errors', '1');
error_reporting(E_ALL);
header('Content-type: application/json; charset=utf-8');
$name=$_REQUEST['name'];

if(!empty($name))
{
    $dist=GetAddress($name);
    echo $dist;
}

//calculate distance
function GetAddress($name)
{
    $dbhost = "localhost";
    $dbuser = "perthdes_inquiri";
    $dbpass = "@G&{)0*&Ts^V";
    $dbname = "perthdes_inquiries";
    $conn = new mysqli($dbhost, $dbuser, $dbpass, $dbname) or die($conn->connect_error);

    $query = "select id, inquiry_name, inquiry_mobile, inquiry_email, inquiry_dropoff from inquiries where inquiry_name = '".$name."' ORDER BY id DESC LIMIT 0,1";
    $result = mysqli_query($conn, $query);
    $row = mysqli_fetch_assoc($result);
    $user=array('id'=> $row['id'],'name'=> $row['inquiry_name'],'mobile'=> $row['inquiry_mobile'],'email'=> $row['inquiry_email'],'pickup'=> $row['inquiry_dropoff']);
    return json_encode($user, true);
}