<?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);
// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

$response=array();



$sql="SELECT schedule_exam.*,seatingarrangements.room_id FROM schedule_exam INNER JOIN seatingarrangements ON seatingarrangements.date = schedule_exam.dates AND seatingarrangements.time = schedule_exam.timess AND seatingarrangements.course_id = schedule_exam.course_id AND seatingarrangements.season_id = schedule_exam.season_id AND seatingarrangements.exams_id = schedule_exam.exams_id";

$result=mysqli_query($con,$sql);

    while ($row=mysqli_fetch_array($result)) {  

   
     $course_id =$row["course_id"];
     $season_id =$row["season_id"];
     $exams_id =$row["exams_id"];
    $paper =$row["paper"];
     $slots =$row["slots"];
    $room_id =$row["room_id"];


////// sql_combine_exam_pre_ops = sqlceps////
$sqlceps = "SELECT * FROM set_student_exampre WHERE course_id = '$course_id' AND season_id = '$season_id' AND exams_id = '$exams_id' AND paper = '$paper' AND slots = '$slots'";

$result_sqlceps=mysqli_query($con,$sqlceps);

  while ($row_sqlceps=mysqli_fetch_array($result_sqlceps)) {  

   
     $roll_number[] =$row_sqlceps["roll_number"];
     $student_name =$row_sqlceps["student_name"]; 

                                                  

    }

    echo json_encode($user);



}


?>