<?php
session_start();
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST');
header("Access-Control-Allow-Headers: X-Requested-With");
header('Content-Type: application/json; charset=utf-8');

include 'config.php';



function check_input($par) {
  $par = trim($par);
  $par = stripslashes($par);
  $par = htmlspecialchars($par);
  return $par;
}






$sql="SELECT * FROM country ORDER BY  name ASC";
$result=$con->query($sql) or die ("error: Server error ".mysqli_error($con));


if($result)
{
$data = array();

while($rows=mysqli_fetch_assoc($result))
   {
    $data[] = $rows;
   $suc="Success";
   $url=$p_url."/flags/";
   }
   if($data == null)
   {
      $suc="No Countries";
       $data = ''; 
   }

}

$con->close();

header('Content-Type: application/json; charset=utf-8');
$output = array('success'=>$suc, 'data'=> $data);
echo json_encode($output); //output JSON data
//mysql_close($con);
?>

