Ver Mensaje Individual
  #1 (permalink)  
Antiguo 15/07/2014, 15:12
esmipc
 
Fecha de Ingreso: julio-2014
Mensajes: 6
Antigüedad: 9 años, 9 meses
Puntos: 0
Generar campos de texto de acurdo al numero de registros

Hola buen dia soy nuevo en php y nuevo en el foro pero necesito de su gran ayuda. he encontrado un ejemplo que se acomoda a mis necesidades.
lo que quiero es generar compos de texto dependiendo del numero de registros de mi tabla para ingresar unas notas de alumnos y luego guardarlas en una tabla.
tengo este ejemplo pero no me guarda loq quiero:


<?php
$mysqli = new mysqli('localhost', 'root','root', 'siadace01' );
$sql = "SELECT V_codi_est,V_nombre,V_apellido FROM tb_estudiantes";
$consulta = $mysqli->query($sql);
?>
<form action="guardar.php" method="post">
<table width="314" border="1">

<tr>
<td height="26" colspan="2">LISTA DE ESTUDIANTES </td>
</tr>
<tr>
<td width="137"><strong>Guardar Notas</strong></td>
<td width="161" height="26"><input type="submit" value="Guardar" /></td>
</tr>
</table>

<table cellpadding="0" cellspacing="5" border="0" class="bordered-table zebra-striped" id="registro">
<thead>
<tr bgcolor="#a6cbea">
<th>Dui</th>
<th>Nombre</th>
<th>Apellido</th>
<!-- <th><font color="blue">Modificar</font></th>
--> <th><font color="red"> (Seleccionar)</font></th>
</tr>
</thead>
<tbody>
<?php
while ($filas = $consulta->fetch_assoc())
{

echo '<tr>';
echo '<td ><a><font color="black">'.utf8_encode ($filas['V_codi_est']).'</a></td>';
echo '<td><a><font color="black">'.utf8_encode ($filas['V_nombre']).'</a></td>';
echo '<td><a><font color="black">'.utf8_encode ($filas['V_apellido']).'</a></td>';
//echo '<td ><a href=../form_act_personal.php?dui='.$filas['V_codi_est'].'><font color="blue">'.utf8_encode ('MODIFICAR').'</a></td>';
echo '<td><input type="checkbox" name="casilla[]" value='.utf8_encode ($filas['V_codi_est']).'></td>';
echo '<td><input type="text" name="nota1" size="2" ></td>';
echo '<td><input type="text" name="nota2" size="2"></td>';
echo '<td><input type="text" name="nota3" size="2"></td>';
echo '</tr>';
}
?>
<tbody>
</table>
</form>
AQUI ME GENERA CASILLAS PARA PODER INTRUDUCIR DATOS CON OTRO ARCHIVO LOS QUIERO ALMACENAR

ASI:
GUARDA:

<?php

include 'conexion.php';

$con=conexion();

$x=$_POST[casilla];
$not1=$_POST[nota1];
$not2=$_POST[nota2];
$not3=$_POST[nota3];

foreach ($x as $value){

$res=mysql_query("INSERT INTO `tb_notas`(`V_codi_est`,`C_id_asignatura`,`C_per_t ri`,`F_nota_1`,`F_nota_2`,`F_nota_3`,V_anio_lect) VALUES ('$value','a','b','$not1','$not2','$not3','2014')" ,$con);
if($res){

echo 'Dato GUARDADOS correctamente<br />';

}

}

?>


PERO EL DETALLE ES QUE SOLO ME GUARDA EL ULTIMO VALOR DE LAS NOTAS EN TODOS LOS REGISTROS PERO LOS CODIGOS ME LOS ALMACENA CORRECTAMENTE PERO NO LAS NOTAS.