<?php
require_once 'config.php';
//$error=false;
$errors=array();
$cities=array();

$query="SELECT * FROM vouchers_logs WHERE user_id=".$_GET['user_id']." ORDER BY id DESC";

$row = mysqli_query($con,$query);
     
    if (mysqli_num_rows($row) >= 1) {
		//$r=mysqli_fetch_array($row)	;
			
		 while($r=mysqli_fetch_array($row)){
			 
			
			 $cat=mysqli_fetch_array(mysqli_query($con,"SELECT * FROM users WHERE id=".$r['user_id']));
			 
			$cities[]=['logid'=>$r['id'],'user_id'=>$r['user_id'],'Availablevoucher'=>$r['voucher'],'dailyvoucher'=>$r['voucher'],'difference'=>$r['difference'],'type'=>'RLS','date'=>$r['created_at']];
			
			
			
		}   
		$errors['voucherlog']=$cities;
		
		$errors['success']='Daily Voucher log history data';
    } else {
        
		$errors['success']='There is no log found';
    }
	echo json_encode($errors);
?>