Cita:
Iniciado por gnzsoloyo
¿Tienes algún impedimento para mostrar el código
completo?
Acá nadie te va a plagiar... hacerlo con un código que no está funcionando bien es un despropósito.
Te pondre el codigo en dos partes, porque es muy largo:
Parte 1:
Código PHP:
If(isset($_SESSION['tmp_trimestre'])){
$TrimestreSesion=$_SESSION['tmp_trimestre'];
$TrayectoSesion=$_SESSION['tmp_trayecto'];
$TrayectoSec=$_SESSION['tmp_trayecto'];
$pensum=$_SESSION['tmp_pensum'];
}
if($TrimestreSesion==3){
$query_numero=mysql_query("SELECT COUNT( * ) AS Divisor FROM ma_asignaturas_pnf WHERE descripcion LIKE '".$materia_descripcion."' AND pensum='".$pensum."' AND trayecto ='".$TrayectoSesion."'",$conexion);
$re_query_numero=mysql_fetch_array($query_numero);
$numero_divisor=$re_query_numero['Divisor'];
$query_info=mysql_query("SELECT trimestre,cohorte,anio FROM tr_secciones_pnf WHERE codigo_id='".$_SESSION['tmpSeccion']."' and anio='".$_SESSION['anio_periodo']."' and cohorte='".$_SESSION['periodo']."'",$conexion);
$re_query_info=mysql_fetch_array($query_info);
$TrimestreSec=$re_query_info['trimestre'];
$CohorteSec=$re_query_info['cohorte'];
$AnioSec=$re_query_info['anio'];
$usuario=$_SESSION['user'];
$fechaInicial=DATE("Y-m-d/h:i:s", $fechaSS );
if(array_key_exists('cedulaEst', $_POST)&& array_key_exists('notaTrimestre3', $_POST)){
$cedulaEst = $_POST['cedulaEst'][0];
$notaTrimestre3 = $_POST['notaTrimestre3'][0];
$ValidarUpdate=mysql_query("SELECT * FROM nota_tercer_trimestre WHERE cod_seccion='".$_SESSION['tmpSeccion']."' and cod_asignatura='".$_SESSION['tmpAsignatura']."' and anio='".$_SESSION['anio_periodo']."' and periodo='".$CohorteSec."' and trimestre='".$TrimestreSec."' and trayecto='".$TrayectoSec."'",$conexion);
$UpdateValidacion=mysql_num_rows($ValidarUpdate);
if($UpdateValidacion>0){
// Updateamos Las Tablas de Notas
for($i=0;$i<count($_POST["cedulaEst"]); $i++){
$cedulaEst="".$_POST['cedulaEst'][$i]."";
$notaTrimestre3="".$_POST['notaTrimestre3'][$i]."";
//Obtenemos los Valores de los Porcentajes
//Determinamos en Que Period y Año se encuentran lso Trimestres 2 y 1.
if($CohorteSec==2){
//Trimestre 2 = Periodo 1. (Del mismo año)
$periodo_trimestre2 = $CohorteSec - 1;
$trimestre_porcentaje2 = mysql_query("SELECT porcentaje, nota_segundo_trimestre, cod_docente, fecha_carga FROM nota_segundo_trimestre WHERE cod_asignatura='".$_SESSION['tmpAsignatura']."' and anio='".$_SESSION['anio_periodo']."' and periodo='".$periodo_trimestre2."' and trimestre='2' and trayecto='".$TrayectoSec."'",$conexion);
$valor_procentaje2 = mysql_fetch_array($trimestre_porcentaje2);
$porcentaje_trimestre2 = $valor_procentaje2['porcentaje'];
$nota_trimestre2 = $valor_procentaje2['nota_segundo_trimestre'];
$Nota_total2 = ($nota_trimestre2 * $porcentaje_trimestre2) / 100;
$Fecha_trimestre2 = $valor_procentaje2['fecha_carga'];
$Docente_trimestre2 = $valor_procentaje2['cod_docente'];
$anio_trimestre = $AnioSec - 1;
$periodo_trimestre1= $CohorteSec;
$trimestre_porcentaje1 = mysql_query("SELECT porcentaje, nota_primer_trimestre, cod_docente, fecha_carga FROM nota_primer_trimestre WHERE cod_asignatura='".$_SESSION['tmpAsignatura']."' and anio='".$anio_trimestre."' and periodo='".$periodo_trimestre1."' and trimestre='1' and trayecto='".$TrayectoSec."'",$conexion);
$valor_procentaje1 = mysql_fetch_array($trimestre_porcentaje1);
$porcentaje_trimestre1 = $valor_procentaje1['porcentaje'];
$nota_trimestre1 = $valor_procentaje1['nota_primer_trimestre'];
$Nota_total1 = ($nota_trimestre1 * $porcentaje_trimestre1) / 100;
$Fecha_trimestre1 = $valor_procentaje1['fecha_carga'];
$Docente_trimestre1 = $valor_procentaje1['cod_docente'];
$Porcentaje_tercer_trimestre = 100 - ($porcentaje_trimestre1 + $porcentaje_trimestre2);
}elseif($CohorteSec==1){
$anio_trimestre2 = $AnioSec - 1;
$periodo_trimestre2= $CohorteSec + 1;
$trimestre_porcentaje2 = mysql_query("SELECT porcentaje, nota_segundo_trimestre, cod_docente, fecha_carga FROM nota_segundo_trimestre WHERE cod_asignatura='".$_SESSION['tmpAsignatura']."' and anio='".$anio_trimestre2."' and periodo='".$periodo_trimestre2."' and trimestre='2' and trayecto='".$TrayectoSec."'",$conexion);
$valor_procentaje2 = mysql_fetch_array($trimestre_porcentaje2);
$porcentaje_trimestre2 = $valor_procentaje2['porcentaje'];
$nota_trimestre2 = $valor_procentaje2['nota_segundo_trimestre'];
$Nota_total2 = ($nota_trimestre2 * $porcentaje_trimestre2) / 100;
$Fecha_trimestre2 = $valor_procentaje2['fecha_carga'];
$Docente_trimestre2 = $valor_procentaje2['cod_docente'];
$anio_trimestre1 = $AnioSec - 1;
$periodo_trimestre1= $CohorteSec;
$trimestre_porcentaje1 = mysql_query("SELECT porcentaje, nota_primer_trimestre, cod_docente, fecha_carga FROM nota_primer_trimestre WHERE cod_asignatura='".$_SESSION['tmpAsignatura']."' and anio='".$anio_trimestre1."' and periodo='".$periodo_trimestre1."' and trimestre='1' and trayecto='".$TrayectoSec."'",$conexion);
$valor_procentaje1 = mysql_fetch_array($trimestre_porcentaje1);
$porcentaje_trimestre1 = $valor_procentaje1['porcentaje'];
$nota_trimestre1 = $valor_procentaje1['nota_primer_trimestre'];
$Nota_total1 = ($nota_trimestre1 * $porcentaje_trimestre1) / 100;
$Fecha_trimestre1 = $valor_procentaje1['fecha_carga'];
$Docente_trimestre1 = $valor_procentaje1['cod_docente'];
$Porcentaje_tercer_trimestre = 100 - ($porcentaje_trimestre1 + $porcentaje_trimestre2);
}
//Nota con Procentaje del Trimestre 3
$Nota_total3 = ( $notaTrimestre3 * $Porcentaje_tercer_trimestre) / 100;
$Nota_totalS = $Nota_total1 + $Nota_total2 + $Nota_total3;
$Nota_total = round($Nota_totalS,1);
$insertar_nota = mysql_query("UPDATE nota_tercer_trimestre SET nota_tercer_trimestre='".$notaTrimestre3."', fecha_carga='$fechaInicial', porcentaje='$Porcentaje_tercer_trimestre'
WHERE cod_estudiante='".$cedulaEst."'
AND cod_asignatura='".$_SESSION['tmpAsignatura']."'
and cod_seccion='".$_SESSION['tmpSeccion']."'
and anio='".$AnioSec."'
and periodo='".$CohorteSec."'
and trimestre='".$TrimestreSec."'
and trayecto='".$TrayectoSec."'",$conexion);
$insertar_nota = mysql_query("UPDATE tr_nota_pnf SET nota_tercer_trimestre='".$notaTrimestre3."', fecha_tercer_trimestre='$fechaInicial', porcentaje_tercer_trimestre='$Porcentaje_tercer_trimestre', promedio='".$Nota_total."'
WHERE cod_estudiante='".$cedulaEst."'
AND cod_asignatura='".$_SESSION['tmpAsignatura']."'
and cod_seccion='".$_SESSION['tmpSeccion']."'
and anio='".$AnioSec."'
and periodo='".$CohorteSec."'
and trayecto='".$TrayectoSec."'",$conexion);
$eliminar_reprobados = mysql_query("DELETE FROM materia_reprobada_pnf WHERE cedula='".$cedulaEst."' and codigo_seccion='".$_SESSION['tmpSeccion']."' and codigo_materia='".$_SESSION['tmpAsignatura']."' and periodo='".$CohorteSec."' and anio='".$_SESSION['anio_periodo']."' and trayecto='".$TrayectoSec."'",$conexion);
}//fin for
}//FIN DE LA VALIDACION
// INSERTAMSO LOS DATOS EN LA BASE DE DATOS
else{