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

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

 

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

$response=array();

 


if(isset($main_topics_id)){
		$sql="SELECT * FROM sub_topics WHERE main_topics_id='$main_topics_id'";
}
else{
		$sql="SELECT * FROM sub_topics";
}





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

    while ($row[]=mysqli_fetch_assoc($result)) {  

      $user=$row;

//     	$array1 = array("5","26","38","42");

// $array2 = array("15","36","38","42");

//     	$user = array_intersect($array1, $array2);

    }
// foreach ($user as &$value) {
//     $intersect[] = $value;

//      	$providers = array_intersect($intersect[$value]);

// }
      // echo json_encode($course_id);
      // echo json_encode($dept_id);


echo json_encode($user);




?>