<?php 
include("auth.php");
include("config.php");

$coursesearch = $_REQUEST['coursesearch'];

$where_course = '';
if($showcourseids){
	$where_course = " AND id IN (".$showcourseids.")";
}
if(!$showhiddencourses){
	$where_course .= " AND visible = '1' ";
}

if($coursesearch){	
	$course_query = "SELECT * FROM ".$database_prefix."course WHERE id != '1' AND fullname LIKE '%".$coursesearch."%' ".$where_course;
}else{	
	$course_query = "SELECT * FROM ".$database_prefix."course WHERE id != '1'  ".$where_course;
}

$result_course = mysqli_query($con,$course_query) or die(mysqli_error($con));
$no_course_rows = mysqli_num_rows($result_course);
$response = '';
if($no_course_rows >0){ 
	
	 while($row_course = mysqli_fetch_array($result_course,MYSQLI_ASSOC)) {
			$response .= '<tr><td class="check"><input type="checkbox" name="courses[]" class="form-check-input" value="'.$row_course['id'].'"></td><td>'.$row_course['fullname'].'</td></tr>';
	 }
	
}
echo $response;
?>
