<?php


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');
$paper = $request->getAttribute('paper');

if(mysqli_connect_errno())
{
	echo "Failed to connect mysqli".mysqli_connect_errno();
}


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

$sql_seat="SELECT * FROM set_student_season WHERE course_id = '$course_id' AND session_id = '$season_id'";

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

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


// $user_seat[$i] = json_decode($row_seat['papers_undertaking']);


// for($j=0;$j<count($user_seat[$i]);$j++)
// {
//     if($user_seat[$i][$j] == $paper)
//     {
//         $paper_list_data[] = $row_seat['rollnumber'];
//         $paper_liststudent_data[] = $row_seat['student_name'];
        
       
//     }
  
// }

// $rollnumber_data[$i][] = $paper_list_data[$i];
// $rollnumber_data[$i][] = $paper_liststudent_data[$i];
// $rollnumber_data[$i][] = 'false';

//  $keys = array('rollnumber','student_name','checked');

// $final_data[] = array_combine($keys,$rollnumber_data[$i]);

// $i++;
// }





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


$user_seat[$i] = json_decode($row_seat['papers_undertaking']);
$get_roll_number[$i] = $row_seat['rollnumber'];
$get_student_name[$i] = $row_seat['student_name'];


$i++;
}

for($h=0;$h<count($user_seat);$h++)
{
for($j=0;$j<count($user_seat[$h]);$j++)
{
    if($user_seat[$h][$j] == $paper)
    {
        // $paper_list_data[] = $get_roll_number[$h];
        // $paper_liststudent_data[] = $get_student_name[$h];


$rollnumber_data[$h][] = $get_roll_number[$h];
$rollnumber_data[$h][] = $get_student_name[$h];
$rollnumber_data[$h][] = 'false';

       $keys = array('rollnumber','student_name','checked');

$final_data[] = array_combine($keys,$rollnumber_data[$h]);
    }
  
}

}


  echo json_encode($final_data);

    
  
?>