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

$query='SELECT * FROM coupons 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)){
			 
			$cities[]=['id'=>$r['id'],'coupon_code'=>$r['coupon_code'],'discount_type'=>$r['discount_type'],'discount'=>$r['discount'],'start_date'=>$r['start_date'],'end_date'=>$r['end_date']];
			
			// $cities['images']=$images;
			
			
		}   
		$errors['coupons']=$cities;
		//$errors['product_images']=$images;
		$errors['success']='coupons data';
    } else {
        
		$errors['success']='There is no banners found';
    }
	echo json_encode($errors);
?>