<?php

require_once("../config/configDB.php"); 
//productID='".$_GET['pid']."' and

$cid= $_GET['cid'];
$pid= $_GET['pid'];

$sql_gst=mysqli_query($conn,"SELECT * FROM product_master WHERE   id='".$pid."' ");
		$row_master_gst=mysqli_fetch_array($sql_gst,MYSQLI_ASSOC);
if($cid=="Gold")
{
$result = mysqli_query($conn,"SELECT old_gold_rate as rate FROM gold_rate WHERE   status=''   ");
}
else
{
$result = mysqli_query($conn,"SELECT  old_silver_rate as rate FROM gold_rate WHERE   status=''   ");
}

$res = array(); 
		
while($row = mysqli_fetch_array($result)){

	
	if($row['rate']==0)
	{
		//$row['sale_rate']  = number_format(($row['purchase_rate']*100/118),2,'.','');
		$row['rate']  = number_format(($row['rate']),2,'.','');
	}


	array_push($res, array(
		"purchase_rate"=>($row['rate']),
		//"sale_rate"=>number_format(($row['sale_rate']*100/118),2,'.',''),
		"sale_rate"=>number_format(($row['rate']),2,'.',''),
		"gst"=>$row_master_gst['gst']
        	) 
 		);
 	}
 	echo json_encode($res);

//echo "tesing".$_GET['key'];




?>