<?php  
session_start(); 
if(!isset($_SESSION['tulsilogin']))
	{
		header('Location: index.php');
		return;
	}

	include("connect.php");	header("Access-Control-Allow-Origin: *");
	
	$eve = "select * from res_country_master";
	$re = mysqli_query($conn, $eve);	
	
	$response = array();
	$posts = array();
	
	$result="0";
	
	if(mysqli_num_rows($re) > 0)
	{
		$i=1;
		 while($rt = mysqli_fetch_assoc($re))
		 {
			 $attechment=$rt['attechment'];;	
				$countrymid=$rt['countrymid'];
				$countrycode=$rt['countrycode'];
				$countrycurrency=$rt['countrycurrency'];
				
				$pidedit="<a href='countryedit.php?id=".$rt['countrymid']."' data-toggle='tooltip' data-placement='top' title='Edit' class='fa fa-edit fa-lg'>  </a>";
				
				if ($attechment != ""){
				
				   $attechment="<a target='_blank' href='docs/$attechment'>download</a>";
				}
				else
				{
					$attechment="";
				}
				
				
				$piddelete="<a href='countrydelete.php?id=".$rt['countrymid']."'onclick='return confirm(&#39;Are you sure you want to delete ?&#39;);' data-toggle='tooltip' data-placement='top' title='Delete' class='far fa-trash-alt fa-lg'>  </a>";			
                $op=$pidedit."&nbsp;&nbsp;&nbsp; ".$piddelete;
								
								
				$countryname=str_replace ("'","'",$rt['countryname']);
				$countryname=str_replace ('"','\"',$countryname);
				
				
								
				$posts[] = array('srno'=> $i++,'op'=> $op,'piddelete'=> $piddelete, 'countryname'=> $countryname, 'attechment'=> $attechment, 'countrycode'=> $countrycode, 'countrycurrency'=> $countrycurrency);
		 }
		 
		$response['posts'] = $posts;
		echo stripslashes(json_encode( array('data' => $posts)));
		mysqli_close($conn);
		return;
	}
	
   else
   {
		$result="0";
		$msg="Invalid Error";
		
		$posts[] = array('p1'=> $result,'p2'=> $msg);
	
		$response['posts'] = $posts;
		echo stripslashes(json_encode( array('item' => $posts)));
   }   
	mysqli_close($conn);	
	
?>