Ver Mensaje Individual
  #3 (permalink)  
Antiguo 16/07/2012, 09:17
elegidoneo1
 
Fecha de Ingreso: abril-2010
Mensajes: 2
Antigüedad: 14 años, 1 mes
Puntos: 1
Respuesta: como insertar registros en masa

Buenas amigo(a) supongamos que en la base de datos tienes id,nombre,grado,etc..., y lo que quieres hacer es poner la nota de cada uno de los estudiantes y al guardar te la guarde en cada uno de ellos esta es la solucion:
Código PHP:
Ver original
  1. $consulta="SELECT* FROM alumnos WHERE Grado=segundo";
  2. $resultado=mysql_query($consulta,conexion);
  3.  
  4. echo '<table borde="1">';
  5. echo '<tr>';
  6. echo '<th>'.'nombres'.'</th>';
  7. echo '<th>'.'grado'.'</th>';
  8. echo '<th>'.'Nota'.'</th>';
  9. echo '<tr>';
  10. while($fila=mysql_fetch_array($resultado))
  11. {
  12. echo '</tr>';
  13. echo '<th>'.'$fila['Nombre']'.'</th>';
  14. echo '<th>'.'$fila['Grado']'.'</th>';
  15. echo '<th>
  16. <form action="" method="post" name="formulario">
  17. <input type="text" name="nota[]" /><input name="id_estudiante[]" type="hidden" value="'.'$fila['id_estudiante']'.'" /></form></th>';
  18. echo '</tr>';
  19. }
  20. echo '</table>';

y en donde procesa la nota pon asi
Código PHP:
Ver original
  1. foreach($_POST['id_estudiante'] as $valor){
  2.   $consulta="UPDATE alumnos SET '.$_POST['nota'][$valor] .' WHERE id_estudiante=".$valor;
  3. $resultado=mysql_query($consulta,conexion);
  4. }