<?php
require_once 'config.php';
//$error=false;
$errors=array();
$cities=array();
 $user_id=$_GET['user_id'];
 
$user=mysqli_fetch_array(mysqli_query($con,"SELECT * FROM users WHERE id=".$user_id));

$query='SELECT * FROM flyers WHERE merchant_phone='.$user['phone'];


$row = mysqli_query($con,$query);
     
    if (mysqli_num_rows($row) >= 1) {
		
			
		 while($r=mysqli_fetch_array($row)){
			 $str = str_replace('\\', '/', $r['front_flyer']);
			 $str1 = str_replace('\\', '/', $r['back_flyer']);
			$cities[]=['id'=>$r['id'],'country_id'=>$r['country_id'],'city_id'=>$r['city_id'],'cate_id'=>$r['cate_id'],'merchant_title'=>$r['merchant_title'],'merchant_url'=>$r['merchant_url'],'no_of_flyer'=>$r['no_of_flyer'],'merchant_email'=>$r['merchant_email'],'merchant_phone'=>$r['merchant_phone'],'front_flyer'=> $str,'back_flyer'=> $str1];
			
			
		}   
		$errors['flyers']=$cities;
		$errors['success']='flyers data';
    } else {
        
		$errors['success']='There is no flyers found';
    }
	echo json_encode($errors);
?>