<?php
ob_start();
include("../connect.php");
$response=array();
if(isset($_POST['brand_id']))
{ 
    $b_id = $_POST['brand_id']; 
	$res = mysqli_query($con,"SELECT * FROM tbl_master_category where brand_id='$b_id'");
	$row=mysqli_num_rows($res);
	if($row>0) 
	{	
      $categories=array();
       while($row=mysqli_fetch_array($res))
	   {  
          $category['category_id'] = $row['category_id'];
		  $category['category_name'] = $row['category_name'];
		  $c_id=$row['category_id'];
		  
		  
		  $res1 = mysqli_query($con,"SELECT * FROM `tbl_master_product` where category_id='$c_id'");
          $category['product']=array();
		   while($row1=mysqli_fetch_array($res1))
		   {
			$product['product_id'] = $row1['product_id'];
			$product['product_name'] = $row1['product_name'];
			$product['product_price'] = $row1['product_price'];
			$product['warranty'] = $row1['warranty'];	
			$product['warranty_description'] = $row1['warranty_description'];
			$product['status'] = $row1['status'];
            $category['product'][]=$product;		
		   }
		   
		  $response['categories'][]=$category;	   
	   }

	   $response['success']=1;
	   $response['details']="Product Detail Fetched Succesfully";  
	}
    else
	{
		$response['success']=0;
		$response['details']="Product Detail Not Available...!!";
	} 
}
else
{	
	$response['success']=0;
	$response['details']="Required fields missing";
}
echo json_encode($response);
?> 