//http://127.0.0.1/p/api/api.php?order_id=4
// Enter your Host, username, password, database below.
$con = mysqli_connect("xx.xx.8x.x","xxxxxot","xx","demo_db");
    if (mysqli_connect_errno()){
 echo "Failed to connect to MySQL: " . mysqli_connect_error();
 die();
 }
header("Content-Type:application/json");
if (isset($_GET['id']) && $_GET['id']!="") {
 //include('db.php');
 $id = $_GET['id'];
 $result = mysqli_query(
 $con,
 "SELECT * FROM `student` WHERE id=$id");
 if(mysqli_num_rows($result)>0){
 $row = mysqli_fetch_array($result);
 $class= $row['class'];
 $first_name = $row['first_name'];
 $last_name = $row['last_name'];
 response($id, $class, $first_name,$last_name);
 mysqli_close($con);
 }else{
 response(NULL, NULL, 200,"No Record Found");
 }
}else{
 response(NULL, NULL, 400,"Invalid Request");
 }
 
function response($id,$class,$first_name,$last_name){
 $response['id'] = $id;
 $response['class'] = $class;
 $response['first_name'] = $first_name;
 $response['last_name'] = $last_name;
 
 $json_response = json_encode($response);
 echo $json_response;
}
?>