<?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 counseling ORDER BY id DESC LIMIT 0, 50";
$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."/counsels/";
   }
   if($data == null)
   {
      $suc="No Counsellors";
       $data = ''; 
   }

}

$con->close();

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

