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

$query='SELECT SUM(credits) as earn FROM credit_logs WHERE user_id='.$_GET['user_id'];

$row = mysqli_query($con,$query);
     
    if (mysqli_num_rows($row) >= 1) {
		//$r=mysqli_fetch_array($row)	;
			
		 while($r=mysqli_fetch_array($row)){
			$cities=$r['earn'];
			
			
		}   
		$errors['earning']=$cities;
		$errors['success']='earning data';
    } else {
        
		$errors['success']='There is no earning found';
    }
	echo json_encode($errors);
?>