<?php
	//$conn = new mysqli('localhost', 'agtechsr_user', 'Alefortress8.', 'agtechsr_crm') or die(mysqli_error());	
	$conn = new mysqli('localhost', 'root', 'S1stemas', 'coplumu') or die(mysqli_error());	
	$id_departamento=intval($_REQUEST['area_id']);
	$municipios = $conn->prepare("select c.id as id, c.name as cname, c.hour as hour ,m.name as mname,count(u.id) as count from mode as m ,course as c left join user_admission as u on u.course_i_id = c.id where m.id = c.mode_id and c.area_id = 1 and c.type =2 group by c.id") or die(mysqli_error());
		echo '<option value = "">--SELECCIONA--</option>';
	if($municipios->execute()){
		$a_result = $municipios->get_result();
	}

		while($row = $a_result->fetch_array()){
			if($row['count']<5){
				echo '<option value = "'.$row['id'].'">'.utf8_encode( $row['cname'])." ".utf8_encode( $row['hour']).'</option>';
			}
		}
?>