<?php 
 
 require 'db.php';
$data = json_decode(file_get_contents('php://input'), true);
$uid = $data['uid'];

if($uid == '')
{
	$returnArr = array("ResponseCode"=>"401","Result"=>"false","ResponseMsg"=>"Something Went wrong  try again !");
}
else 
{
    $user = $con->query("select * from user where id = '$uid'");
    if($row_user = $user->fetch_assoc()) {
        $coins = $row_user['coins'];
    }
    
	$cy = $con->query("select * from coin_transactions where uid='$uid' order by id DESC");
	$count = $con->query("select * from coin_transactions where uid='$uid'")->num_rows;
	if($count != 0)
	{
    	$p = array();
    	$q = array();
    	while($row = $cy->fetch_assoc())
    	{
    		$p['id'] = $row['id'];
    		$p['name'] = $row['name'];
    		$p['coins'] = $row['coins'];
    		$p['coin_type'] = $row['coin_type'];
    		$p['c_date'] = $row['c_date'];
            $p['c_time'] = $row['c_time'];
    		$q[] = $p;
    	}
    	$returnArr = array("ResponseCode"=>"200","Result"=>"true","ResponseMsg"=>"Coin Transactions Get Successfully","ResultData"=>$q,"coins"=>$coins);
    }
    else 
    {
    	$returnArr = array("ResponseCode"=>"401","Result"=>"false","ResponseMsg"=>"No Coin Transactions!");
    }
}
echo json_encode($returnArr);
mysqli_close($con);
?> 	