<?php
// array for JSON response
	$response= array();
  
	//$password='ge4lnkWWY^WpqqL#u1Qg';
	//$username='id12214488_user1';
	//$dbname='id12214488_shadihallproject';
//	$servername = "localhost";
  

    // include db connect class
    require_once __DIR__ . '/../DBConnect.php';
	if(isset($_POST['ClientID'])){
		$clientid=$_POST['ClientID'];
			try {
			//$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
			//$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
			 $sql = "SELECT * FROM Item2Group where ClientID= ".$clientid;
			$stmt = $conn->prepare($sql);
			$stmt->execute();
			$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
			   if($result!=null &&  $result>0){
					$response["Item2Group"] = array();
					foreach($result as $row) { 
						$Item2Group["ID"] = $row["ID"];          
						$Item2Group["Item2GroupID"] = $row["Item2GroupID"]; 
						$Item2Group["Item1TypeID"] = $row["Item1TypeID"];
						$Item2Group["Item2GroupName"] = $row["Item2GroupName"];                                     
						$Item2Group["ClientID"] = $row["ClientID"];    
						$Item2Group["ClientUserID"] = $row["ClientUserID"];
						$Item2Group["NetCode"] = $row["NetCode"];                                          
						$Item2Group["SysCode"] = $row["SysCode"];                                            
						$Item2Group["UpdatedDate"] = $row["UpdatedDate"];
						
					  // push single product into final response array
					  array_push($response["Item2Group"], $Item2Group);

					}
					 // 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"] = "No Data Availaible";
        // echoing JSON response
    		echo json_encode($response);
      }
  $conn = null;
?>
