<?php
// array for JSON response
  $response= array();

    // include db connect class
    require_once __DIR__ . '/../DBConnect.php';
    if (isset($_POST['ID4']) && isset($_POST['SelectedCountryClientID'])) {
        $SelectedCountryClientID = $_POST['SelectedCountryClientID'];
        $ID4 = $_POST['ID4'];
    	try {
		    $sql = "SELECT * FROM AddCategory4 WHERE ID4 > $ID4 AND ClientID = $SelectedCountryClientID";
    		$stmt = $conn->prepare($sql);
    		$stmt->execute();
    		$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
    	   if($result!=null &&  $result>0){
    			 $response["AddCategory4"] = array();
    			foreach($result as $row) { 
    			    $AddCategory4["ID4"] = $row["ID4"];
    				$AddCategory4["ID3"] = $row["ID3"];
    				$AddCategory4["ClientAddNo"] = $row["ClientAddNo"];
    				$AddCategory4["AddStatus"] = $row["AddStatus"];
    				$AddCategory4["AddTitle"] = $row["AddTitle"];
    				$AddCategory4["AddDetail"] = $row["AddDetail"];
    				$AddCategory4["Price"] = $row["Price"];
    				$AddCategory4["AddGPSPostFrom"] = $row["AddGPSPostFrom"];
    				$AddCategory4["AddGPSLocation"] = $row["AddGPSLocation"];
    				$AddCategory4["AddArea"] = $row["AddArea"];
    				$AddCategory4["AddCategory"] = $row["AddCategory"];
    				$AddCategory4["ContactNo"] = $row["ContactNo"];
    				$AddCategory4["NameOfPerson"] = $row["NameOfPerson"];
    				$AddCategory4["ClientID"] = $row["ClientID"];
    				$AddCategory4["ClientUserID"] = $row["ClientUserID"];
    				$AddCategory4["NetCode"] = $row["NetCode"];
    				$AddCategory4["SysCode"] = $row["SysCode"];
    				$AddCategory4["UpdatedDate"] = $row["UpdatedDate"];
    				$AddCategory4["AddPostingDate"] = $row["AddPostingDate"];
    				$AddCategory4["Country"] = $row["Country"];
    				$AddCategory4["City"] = $row["City"];
                    // push single product into final response array
                    array_push($response["AddCategory4"], $AddCategory4);
    			}
    			 // success
    			$response["success"] = 1;
    			// echoing JSON response
    			echo json_encode($response);
    		}else{
    		 // success
    			$response["success"] = 0;
    			$response["message"] = "No Data Availaible";
    		   // echoing JSON response
    			echo json_encode($response);
    				
    		}
    	}
    	catch(PDOException $e){
    		echo "Error: " . $e->getMessage();
    	}
    }else{
	    // success
		$response["success"] = 0;
		$response["message"] = "Set All Parrameters";
	    // echoing JSON response
		echo json_encode($response);
			
	}
  $conn = null; 
?>
