Good, I have a modal where they load me the qualifications of a student, if I want to update those qualifications, only I update the last data.
Attached modal image
Also the code that I have to update on the modal page is:
if(!empty($_POST['nota_act'])){
$id=limpiar($_POST['id2']);
$num = count($id);
for($i=0;$i<$num;$i++)
{
$nota_act=limpiar($_POST['nota_act']);
$num1 = count($nota_act);
print_r($id[$i].'<BR>');
for($z=0;$z<$num1;$z++)
{
print_r($nota_act[$z]);
$oActualizar=new Proceso_Calificar($id[$i],'','','',$nota_act[$z],'','');
$oActualizar->actualizar();
}
}
echo mensajes('Nota Actualizada con Exito','verde');
}
Modal code is as follows:
<div id="a<?php echo $row['periodo'].$row['materia']; ?>" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<form name="form5" method="post" action="">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel" align="center">
Modificar Notas <br>Materia "<?php echo $oMateria->consultar('nombre'); ?>"
</h3>
</div>
<div class="modal-body">
<table class="table table-bordered table table-hover">
<tr class="well">
<td><strong><center>Actividad</center></strong></td>
<td><strong><center>Nota</center></strong></td>
</tr>
<?php
$paa=mysqli_query($conexion,"SELECT * FROM notas
WHERE alumno='".$row['alumno']."' and periodo='".$row['periodo']."' and materia='".$row['materia']."'");
while($dato=mysqli_fetch_array($paa)){
$oAct=new Consultar_Actividad($dato['actividad']);
?>
<tr>
<td><input type="hidden" name="id2[]" value="<?php echo $dato['id']; ?>"><center><?php echo $oAct->consultar('nombre'); ?></center></td>
<td>
<input type="number" min="<?php echo $minima_nota; ?>" max="<?php echo $maxima_nota; ?>" value="<?php echo $dato['valor']; ?>" name="nota_act[]" autocomplete="off" size="4">
</td>
</tr>
<?php } ?>
</table>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true"><strong>Cerrar</strong></button>
<button type="submit" class="btn btn-primary"><strong><i class="icon-refresh"></i> Actualizar</strong></button>
</div>
</form>
And the class in the Classes.php file is:
class Proceso_Calificar extends Conexiones{
var $id; var $materia; var $alumno; var $actividad; var $valor;
var $periodo; var $fecha;
function __construct($id, $materia, $alumno, $actividad, $valor, $periodo, $fecha){
$this->id=$id; $this->materia=$materia;
$this->alumno=$alumno; $this->actividad=$actividad;
$this->valor=$valor; $this->periodo=$periodo; $this->fecha=$fecha;
}
function guardar(){
$id=$this->id; $materia=$this->materia;
$alumno=$this->alumno; $actividad=$this->actividad;
$valor=$this->valor; $periodo=$this->periodo; $fecha=$this->fecha;
parent::__construct();
$sql = "INSERT INTO notas (materia, alumno, actividad, valor, periodo, fecha)
VALUES ('$materia','$alumno','$actividad','$valor','$periodo','$fecha')";
$query = $this->conexion_db->query($sql);
}
function actualizar(){
$id=$this->id; $materia=$this->materia;
$alumno=$this->alumno; $actividad=$this->actividad;
$valor=$this->valor; $periodo=$this->periodo; $fecha=$this->fecha;
parent::__construct();
$sql = "UPDATE notas SET valor='$valor' WHERE id='$id'";
$query = $this->conexion_db->query($sql);
}
}
But only the last data keeps me in this case, unit 4 and the others do not.