faltaba un ; antes del if
quedo asi...
Código PHP:
foreach($clases as $clase){
$q_clase = quoted($clase);
$listaMaterias="('".implode("','", $clases)."')";
$consulta = "SELECT requisito FROM materia WHERE id_materia in $listaMaterias and (requisito IS NOT NULL and requisito NOT IN $listaMaterias)";
$resultado = @mysql_query($consulta, $conexion) or die(mysql_error());
if (mysql_num_rows($resultado)) {
$resultado = mysql_fetch_array($consulta);
$requisitos[] = $resultado["requisito"];
mysql_free_result($resultado);
}
}
for ($i = 0, $limite = count($listasMaterias); $i < $limite; $i++) {
$clave = array_search($listasMaterias[$i], $requisitos);
if ($clave !== FALSE)
echo $requisitos[$clave] . " es un curso requisito de " . $materias_elegidas[$i];
}
#Fin de tabla
echo "</table>";
piePagina();
?>
Pero no se muestra ningún registro...
este es el codigo anterior
Código PHP:
foreach($clases as $clase){
$q_clase = quoted($clase);
$query_precedente = "SELECT M.ID_MATERIA, M.CLAVE, M.NOMBRE FROM MATERIA AS M WHERE M.ID_MATERIA = (SELECT MI.REQUISITO FROM MATERIA AS MI, CLASE AS CI WHERE MI.ID_MATERIA = CI.ID_MATERIA AND CI.ID_CLASE = $q_clase)";
$query_precedente_detalle = "SELECT M.ID_MATERIA, M.CLAVE, M.NOMBRE, DC.CALIFICACION, DC.OPORTUNIDAD, DC.OBSERVACION FROM MATERIA AS M, DETALLE_CARGA AS DC WHERE M.ID_MATERIA = (SELECT MI.REQUISITO FROM MATERIA AS MI, CLASE AS CI WHERE MI.ID_MATERIA = CI.ID_MATERIA AND CI.ID_CLASE = $q_clase) AND M.ID_MATERIA = DC.ID_MATERIA";
$result_precedente = @mysql_query($query_precedente, $conexion) or die(mysql_error());
$filas = mysql_num_rows($result_precedente);
$tiene_precedente = true;
if($filas == 0){
$tiene_precedente = false;
}else{
$precedente = mysql_fetch_array($result_precedente);
$materia = $precedente['CLAVE']." - ".$precedente['NOMBRE'];
$result_precedente_detalle = @mysql_query($query_precedente_detalle, $conexion) or die(mysql_error());
$filas = mysql_num_rows($result_precedente_detalle);
if($filas == 0){
$errores[$clase] = "Requisito no cumplido: $materia";
}else{
$clase_precedente = mysql_fetch_array($result_requisito_detalles);
if(!aprobado($clase_precedente['CALIFICACION'])){
$errores[$clase] = "Requisito no cumplido: $materia ".$clase_precedente['CALIFICACION']." no aprobada.";
}
}
}
$query_clase = "SELECT M.ID_MATERIA, M.CLAVE, M.NOMBRE, M.H_TEORIA, M.H_PRACTICA, M.CREDITOS, (SELECT G.NOMBRE FROM GRUPO AS G WHERE G.ID_GRUPO = C.ID_GRUPO) AS NOMBRE_GRUPO, (SELECT CONCAT(P.TITULO, ' ', P.NOMBRE, ' ', P.P_APELLIDO, ' ', P.S_APELLIDO) FROM PROFESOR AS P WHERE P.ID_PROFESOR = C.ID_PROFESOR) AS NOMBRE_PROFESOR FROM MATERIA M, CLASE C WHERE M.ID_MATERIA = C.ID_MATERIA AND C.ID_CLASE = $q_clase";
$result_clase = @mysql_query($query_clase, $conexion) or die(mysql_error());
$filas = mysql_num_rows($result_clase);
if($filas != 0){#Algo va realmente mal si las filas son 0
$clase = mysql_fetch_array($result_clase);
$creditos_totales = $creditos_totales + $clase['CREDITOS'];
$horas_teoria_totales = $horas_teoria_totales + $clase['H_TEORIA'];
$horas_practica_totales = $horas_practica_totales + $clase['H_PRACTICA'];
echo "<tr>
<td>".$clase['CLAVE']."</td>
<td>".$clase['NOMBRE_PROFESOR']."<br>".$clase['NOMBRE']."</td>
<td>".$clase['NOMBRE_GRUPO']."</td>
<td>".$clase['H_TEORIA']."</td>
<td>".$clase['H_PRACTICA']."</td>
<td>".$clase['CREDITOS']."</td>
</tr>";
}else{
echo "<tr><td colspan=6>No seleccionó materias</td></td></tr>";
}
}
#Totales
echo "<tr>
<td></td>
<td></td>
<td>Totales</td>
<td>".$horas_teoria_totales."</td>
<td>".$horas_practica_totales."</td>
<td>".$creditos_totales."</td>
</tr>";
#Ofrecer inscripción o corregir
foreach($errores as $clase_clave => $error){
echo "<tr>
<td>$clase_clave</td>
<td colspan=5>$error</td>
</tr>";
}
if(count($errores) == 0){ #No hay errores
$_SESSION['carga_autorizada'] = $clases; #Enviando por session
$_SESSION['carga_total_teoria'] = $horas_teoria_totales; #Enviando por session
$_SESSION['carga_total_practica'] = $horas_practica_totales; #Enviando por session
$_SESSION['carga_total_creditos'] = $creditos_totales; #Enviando por session
echo "<tr><td colspan=6><form name=\"operacion\" method=\"post\" action=\"registrar_carga.php\">";
#Si quisiese enviarlos por post, tendria que hacer este truco
foreach($clases as $clase){
echo "<input type=\"hidden\" value=\"$clase\" name=\"clases[]\">";
}
echo "<input type=\"hidden\" value=\"$horas_teoria_totales\" name=\"total_teoria\">
<input type=\"hidden\" value=\"$horas_practica_totales\" name=\"total_practica\">
<input type=\"hidden\" value=\"$creditos_totales\" name=\"total_practica\">";
echo "<input type=\"submit\" value=\"Inscribir\"></form></td></tr>";
}else{
#Deprecated No se pueden enviar un arreglo.
echo "<tr><td colspan=6><form name=\"operacion\" method=\"post\" action=\"show_oferta_academica.php\">
<input type=\"hidden\" value=\"$errores\" name=\"errores\">
<input type=\"submit\" value=\"Corregir\"></form></td></tr>";
}
echo "";
#Fin de tabla
echo "</table>";
piePagina();
?>