
<?php

$con = new mysqli(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);
$set_sections_id=$request->getAttribute('set_sections_id');
$set_Q_papers_id=$request->getAttribute('set_Q_papers_id');


$response=array();
if(isset($set_sections_id)&&isset($set_Q_papers_id)){
$sql="SELECT question_pattern.id, question_pattern.set_sections_id, question_pattern.set_Q_papers_id, question_pattern.set_questions,
	question_pattern.options, set_sections.section_name, set_Q_papers.Q_questions
	FROM (question_pattern INNER JOIN set_sections ON set_sections.id=question_pattern.set_sections_id
	INNER JOIN set_Q_papers ON set_Q_papers.id=question_pattern.set_Q_papers_id
	)
WHERE question_pattern.set_Q_papers_id='$set_Q_papers_id'";
}
elseif(isset($set_sections_id)){
$sql="SELECT question_pattern.id, question_pattern.set_sections_id, question_pattern.set_Q_papers_id, question_pattern.set_questions,
	question_pattern.options, set_sections.section_name, set_Q_papers.Q_questions
	FROM (question_pattern INNER JOIN set_sections ON set_sections.id=question_pattern.set_sections_id
	INNER JOIN set_Q_papers ON set_Q_papers.id=question_pattern.set_Q_papers_id
	
	)
WHERE set_Q_papers.set_sections_id='$set_sections_id'";
}
else{
	$sql="SELECT question_pattern.id, question_pattern.set_sections_id, question_pattern.set_Q_papers_id, question_pattern.set_questions,
	question_pattern.options, set_sections.section_name, set_Q_papers.Q_questions
	FROM (question_pattern INNER JOIN set_sections ON set_sections.id=question_pattern.set_sections_id
	INNER JOIN set_Q_papers ON set_Q_papers.id=question_pattern.set_Q_papers_id
	) ";
}



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

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

      $user=$row;

	}


echo json_encode($user);

?>