<?php
    session_start();
    include 'config.php';
    $uid = $_SESSION['userid'];
    $uname = $_SESSION['uname'];
    $regime_type = $_SESSION['regime_type'];
    $cargo_channel = $_SESSION['cargo_channel'];   
    $searchTerm = $_POST['term'];
    $sql_stmt = "";

    //get matched data from countries table
    if($cargo_channel == 7 && $regime_type == 2)
    {
        // echo "here";
        $sql_stmt = "SELECT * FROM export_land_ports where description LIKE '%$searchTerm%' ";
    }
    else
    {
        $sql_stmt = "SELECT * FROM port_master where country = 'AE' and description LIKE '%$searchTerm%' ";
    }
    $result = mysqli_query($con,$sql_stmt);
    $row = $result->fetch_assoc();
    if($cargo_channel == 7 && $regime_type == 1)
    {
        $data = $row['country'].$row['code'];
    }
    else
    {
        $data = $row['code'];   
    }
    echo $data;
?>