<?php
//Session Start
session_start();

//Ajax Init
include "ajax-init.php";

if(isset($_GET['q'])){

    $search = strip_tags(trim($_GET['q']));
	//countryCode LIKE '$_SESSION[userCountry]%' AND 

    $q = mysqli_query($dbc,"SELECT * FROM customer_tbl WHERE (companyName LIKE '%$search%' OR phoneNum  LIKE '%$search%' OR fullName LIKE '%$search%')");

    if(mysqli_num_rows($q)){
        $data = array();
        while($rows = mysqli_fetch_assoc($q)){
            $data[] = array(
                'id' => $rows['id'],
                'text' => $rows['fullName']." ".$rows['companyName'].' ('.$rows['phoneNum'].')'
            );
        }

        header('Content-type: application/json');
        echo json_encode($data);
        mysqli_close($dbc);
    }

}