Ver Mensaje Individual
  #14 (permalink)  
Antiguo 26/06/2013, 07:30
Avatar de jorge_613
jorge_613
 
Fecha de Ingreso: abril-2011
Ubicación: Maracaibo
Mensajes: 19
Antigüedad: 13 años
Puntos: 0
Sonrisa Respuesta: Problemas al Insertar dentro de un for

Cita:
Iniciado por gnzsoloyo Ver Mensaje
¿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.
Parte 2:

Código PHP:

//HACEMOS EL INSERT EN LA TABLA
for($i=0;$i<count($_POST["cedulaEst"]); $i++){
                    
$cedulaEst="".$_POST['cedulaEst'][$i]."";
                    
$notaTrimestre3="".$_POST['notaTrimestre3'][$i]."";


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_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'][$i];
$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("INSERT INTO nota_tercer_trimestre(cod_estudiante, cod_asignatura, descripcion_materia, pensum, cod_docente, cod_seccion, nota_tercer_trimestre, porcentaje, fecha_carga,anio, periodo, trimestre, trayecto, usuario)  VALUES ('".$cedulaEst."','".$_SESSION['tmpAsignatura']."','".$materia_descripcion."' ,'".$pensum."','".$cod_profesor."','".$_SESSION['tmpSeccion']."','".$notaTrimestre3."','".$Porcentaje_tercer_trimestre."' ,'".$fechaInicial."','".$_SESSION['anio_periodo']."','".$CohorteSec."','".$TrimestreSec."','".$TrayectoSec."','".$usuario."')",$conexion);

$insertar_notas=mysql_query("INSERT INTO tr_nota_pnf(cod_estudiante, cod_asignatura, descripcion_materia, pensum, cod_seccion, porcentaje_primer_trimestre, nota_primer_trimestre, fecha_primer_trimestre, 
                          cod_docente_primer_trimestre, porcentaje_segundo_trimestre, nota_segundo_trimestre, fecha_segundo_trimestre, 
                          cod_docente_segundo_trimestre, porcentaje_tercer_trimestre, nota_tercer_trimestre, fecha_tercer_trimestre, 
                          cod_docente_tercer_trimestre, promedio, anio, periodo ,trayecto, usuario)VALUES('"
.$cedulaEst."', '".$_SESSION['tmpAsignatura']."' ,'".$materia_descripcion."','".$pensum."','".$_SESSION['tmpSeccion']."','".$porcentaje_trimestre1."','".$nota_trimestre1."',
                                    '"
.$Fecha_trimestre1."','".$Docente_trimestre1."','".$porcentaje_trimestre2."','".$nota_trimestre2."','".$Fecha_trimestre2."',
                                    '"
.$Docente_trimestre2."','".$Porcentaje_tercer_trimestre."','".$notaTrimestre3."','".$fechaInicial."','".$cod_profesor."',
                                    '"
.$Nota_total."','".$_SESSION['anio_periodo']."','".$_SESSION['periodo']."','".$TrayectoSec."','".$usuario."')",$conexion);

}
//fin for