<?php require_once('Connections/cn.php'); ?>
<?php
//header("Content-Type:text/html; charset=UTF-8");
header("Content-Type:text/html; charset=utf-8");
$Area= $_REQUEST["id"];
$c= $_REQUEST["c"];
$m= $_REQUEST["m"];
// Realizo la consulta de la Tabla materias filtrando con la carrera que se seleccion�.

mysql_select_db($database_cn, $cn);
mysql_query ("SET NAMES 'utf8'");
$query_materias = "SELECT id_materia,nombre_materia,semestre FROM materias WHERE id_carrera='$c' AND (nivel='$m' or id_mencion='$m') and semestre='$Area' and pensum='6' ORDER BY nombre_materia ";

$rst_materias = mysql_query($query_materias, $cn) or die(mysql_error());
//$row_materias = mysql_fetch_assoc($rst_materias);
$totalRows_materias = mysql_num_rows($rst_materias);  

if($totalRows_materias >0)
{
	$array_select2 = array(0=>"Seleccione...");
	$array_select1 = array(0=>"0");
	$code=1;
	while($materia = mysql_fetch_assoc($rst_materias))
		{
		
			$array_select1[$code] = $materia["id_materia"];		
			$array_select2[$code]=  $materia["nombre_materia"].' ('.$materia["id_materia"].')';	
			$code += 1;
		}
}		

// Bucle para cargar las maetrias en el combo (materias)
for ($i=0; $i<count($array_select2);$i++){
	echo "<option value=".$array_select1[$i].">".$array_select2[$i]."</option>";
}

?>