<?php

/*Student API*/


/*Fetching API*/


/* Attempt to connect to MySQL database */
define('DB_SERVER', 'localhost');
define('DB_USERNAME', 'Restax_final');

define('DB_PASSWORD', 'Restax_final123');

define('DB_NAME', 'Restax_api_data'); 

$con = new mysqli(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);

$id = $request->getAttribute('id');

// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

$response=array();
$g = 0;

//doubt

    // $id=$_POST['id'];
    $sql = "SELECT  * FROM units where set_papers_id= $id";

    $result = $con->query($sql);

    if ($result->num_rows > 0) 
    {
   
    while($row = $result->fetch_assoc())
    {
     // $users=$row;
     $users = json_decode($row['units']);
    }
    //print_r($users);
 
  echo json_encode($users);
 
    
    

    
}
    
    ?>

