<?php 
require_once 'config.php';
$error=false;
$errors=array();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
   
  
	 $json = file_get_contents('php://input');

// Converts it into a PHP object
$data = json_decode($json);
 
   
   //$user_id=$data->user_id;
   
   $user_id=$_POST['user_id'];
  
   $groups=mysqli_fetch_array(mysqli_query($con,"SELECT * FROM popupgroup_scan where user_id=".$user_id."  ORDER BY id DESC LIMIT 1"));
   
   
	//	echo '<pre>';print_r($groups);die;
		
		if(isset($groups) && $groups['is_popup_show']==0){
			//echo "SELECT * FROM popupgroup_images WHERE group_id= ".$groups['id']." ";die;
			 $row1 = mysqli_query($con,"SELECT * FROM popupgroup_images WHERE group_id= ".$groups['popup_id']." ");
			 
			while($r1=mysqli_fetch_array($row1)){
				
			$cities[]=['id'=>$r1['id'],'group_id'=>$r1['group_id'],'image'=>$r1['image'],'created_at'=>$r1['created_at']];
			
			
			
		}   
			$errors['success']=true;						
			$errors['popupimages']=$cities;						
			$errors['message']='Show the popup';
		}else{
			$errors['success']=false;
			$errors['message']="Don't Show the popup";
		}
				
	  
 
		
	
 	 
	 	echo json_encode($errors);
}