<?php  
 

// array for JSON response
  $response= array();

    // include db connect class
    require_once __DIR__ . '/../DBConnect.php';
	try {
		$sql = "SELECT * FROM Account1Type";
		$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
		$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
		$stmt = $conn->prepare($sql);
		$stmt->execute();
		$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
	   if($result!=null &&  $result>0){
			  $response["Account1Type"] = array();
			foreach($result as $row) { 
			
		    $Account1Type["AcTypeID"] = $row["AcTypeID"];
          $Account1Type["AcTypeName"] = $row["AcTypeName"];

          // push single product into final response array
          array_push($response["Account1Type"], $Account1Type);
			}
			 // 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();
		
	}
  $conn = null; 
	  
?>
