<?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"];
$s=$_REQUEST["s"];
$p=$_REQUEST["p"];

if($Area=='CG' || $Area=='CIU') $Area='COMUN';

// 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 id_mencion='$Area' and semestre='$s' and pensum='$p'and substr(id_materia,1,3)='TEG' ORDER BY semestre,nombre_materia";
echo $query_materias;
$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>";
}

?>