Ver Mensaje Individual
  #6 (permalink)  
Antiguo 06/03/2013, 16:32
Avatar de informacionsys
informacionsys
 
Fecha de Ingreso: mayo-2011
Ubicación: Bogota D.C
Mensajes: 793
Antigüedad: 12 años, 11 meses
Puntos: 76
Respuesta: Actualizar Varios Registros a La vez

hola

podria ser asi:

formulario.php

Código HTML:
Ver original
  1. <form action="actualizar_registros.php" name="modificacion" method="post">
  2. <table width="49%" border="1" align="center" rules="rows">
  3. <tr>
  4. <th width="51%" height="34" align="center" style="font:Verdana, Geneva, sans-serif; font-size:12px">Nombres</th>
  5. <th width="49%" align="center" style="font:Verdana, Geneva, sans-serif; font-size:12px">Departamento</th>
  6. </tr>
  7. <tr>
  8. <?php
  9. while($registro = mysql_fetch_array($consulta, MYSQL_ASSOC))
  10. { ?>
  11.     <td height="35" align="center">
  12.     <input type="text" value="<?php echo $registro['nombres']?>" name="nombres[]">
  13.     </td>
  14.     <td align="center">
  15.     <input type="text" value="<?php echo $registro['departamento']?>" name="departamento[]" class="letrapequeña" >
  16.     </td>
  17.   </tr>
  18.  <input type="hidden" value="<?php echo $registro['idempleado']?>" name="idempleado[]">
  19.   <?php
  20.  }
  21. ?>

simplemente listas los usuarios con sus respectivos valores

al enviar el form a

actualizar_registros.php

Código PHP:
Ver original
  1. for ($i = 0; $i < count($_POST['nombres']); $i++)
  2. {
  3.     $update = mysql_query ("UPDATE empleado  SET nombres='{$_POST['nombres'][$i]}',
  4.                                                 departamento='{$_POST['departamento'][$i]}'
  5.                                                 WHERE idempleado='{$_POST['idempleado'][$i]}'",$conex)
  6.                                                  or die ('Problemas con el query'.mysql_error());
  7.  
  8.    echo $update."<br/>";
  9. }

y Listo.....