<?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);

$course_id = $request->getAttribute('course_id'); 
$season_id = $request->getAttribute('season_id'); 
$exams_id = $request->getAttribute('exams_id'); 


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

$response=array();



/////get room number block id number/////

$sql_seat="SELECT * FROM assign_papers WHERE course_id = '$course_id' AND season_id = '$season_id' AND exams_id = '$exams_id'";

$result_seat=mysqli_query($con,$sql_seat);

    while ($row_seat=mysqli_fetch_assoc($result_seat)) {  


$user_seat = json_decode($row_seat['papers_id']);

 //$user_seat = $row_seat['papers_id'];


}




///put student thier rexpective rooms../////

//print_r($user_seat);

// for($loop_data=0;$loop_data<count($user_seat))



//echo print_r($user_seat[0]['time']);


for($i=0;$i<count($user_seat);$i++)
{
	$sql_gt_short="SELECT * FROM set_papers WHERE papers_id = '$user_seat[$i]'";

$result_gt_short=mysqli_query($con,$sql_gt_short);

    while ($row_gt_short=mysqli_fetch_assoc($result_gt_short)) {  


$user_gt_short[] = $row_gt_short['papers_shortcode'];


}

$paper_get_id[$i][] = $user_seat[$i];
$paper_get_id[$i][] = $user_gt_short[$i];

$keys = array('papers_id','papers_shortcode');

$list_keys[] = array_combine($keys, $paper_get_id[$i]);



}


  echo json_encode($list_keys);


?>