<?php
// include db connect class
    require_once __DIR__ . '/../DBConnect.php';
    
    if (isset($_POST['CountryName'])) {
        $CountryName = $_POST['CountryName'];

        $sql = "SELECT ClientID FROM CountryCode WHERE CountryName = '$CountryName'";
        
        $stmt = $conn->prepare($sql);
        $stmt->execute();
        $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
        
        if($result!=null &&  $result>0){
            $response["CountryCode"] = array();
            foreach($result as $row) { 
                $CountryCode["ClientID"] = $row["ClientID"];

                // push single product into final response array
                array_push($response["CountryCode"], $CountryCode);
            }
            // success
            $response["success"] = 1;
            // echoing JSON response
            echo json_encode($response);
        }else {
        // success
        $response["success"] = 0;
        $response["message"] = "No Data Availaible for Update";
        // echoing JSON response
            echo json_encode($response);
        }
    }else {
        // success
        $response["success"] = 0;
        $response["message"] = "Parameters Not Send";
        // echoing JSON response
            echo json_encode($response);
    }
    $conn = null; 
?>