Ver Mensaje Individual
  #4 (permalink)  
Antiguo 20/04/2011, 06:57
Avatar de abimaelrc
abimaelrc
Colaborador
 
Fecha de Ingreso: mayo-2009
Ubicación: En el planeta de Puerto Rico
Mensajes: 14.734
Antigüedad: 15 años
Puntos: 1517
Respuesta: Cargar multiples registros a la misma tabla

Puedes hacerlo usando array en los nombres de los campos.
Código HTML:
Ver original
  1. <input type="text" name="foo[]" /> <input type="text" name="bar[]" /> <input type="text" name="candy[]" /><br />
  2. <input type="text" name="foo[]" /> <input type="text" name="bar[]" /> <input type="text" name="candy[]" /><br />
  3. <input type="text" name="foo[]" /> <input type="text" name="bar[]" /> <input type="text" name="candy[]" /><br />
  4. <input type="text" name="foo[]" /> <input type="text" name="bar[]" /> <input type="text" name="candy[]" /><br />
  5. <input type="text" name="foo[]" /> <input type="text" name="bar[]" /> <input type="text" name="candy[]" /><br />
  6. <input type="text" name="foo[]" /> <input type="text" name="bar[]" /> <input type="text" name="candy[]" /><br />
  7. <input type="text" name="foo[]" /> <input type="text" name="bar[]" /> <input type="text" name="candy[]" /><br />
  8. <input type="text" name="foo[]" /> <input type="text" name="bar[]" /> <input type="text" name="candy[]" /><br />
  9. <input type="text" name="foo[]" /> <input type="text" name="bar[]" /> <input type="text" name="candy[]" /><br />
  10. <input type="text" name="foo[]" /> <input type="text" name="bar[]" /> <input type="text" name="candy[]" /><br />
  11. <input type="text" name="foo[]" /> <input type="text" name="bar[]" /> <input type="text" name="candy[]" /><br />
  12. <input type="text" name="foo[]" /> <input type="text" name="bar[]" /> <input type="text" name="candy[]" /><br />
  13. <input type="text" name="foo[]" /> <input type="text" name="bar[]" /> <input type="text" name="candy[]" /><br />
  14. <input type="text" name="foo[]" /> <input type="text" name="bar[]" /> <input type="text" name="candy[]" /><br />
  15. <input type="text" name="foo[]" /> <input type="text" name="bar[]" /> <input type="text" name="candy[]" /><br />
  16. <input type="text" name="foo[]" /> <input type="text" name="bar[]" /> <input type="text" name="candy[]" /><br />
  17. <input type="text" name="foo[]" /> <input type="text" name="bar[]" /> <input type="text" name="candy[]" /><br />
  18. <input type="text" name="foo[]" /> <input type="text" name="bar[]" /> <input type="text" name="candy[]" /><br />
  19. <input type="text" name="foo[]" /> <input type="text" name="bar[]" /> <input type="text" name="candy[]" />
Luego para leerlo puedes hacer algo así
Código PHP:
Ver original
  1. <?php
  2. if(count($_POST['foo']) == count($_POST['bar']) && count($_POST['foo']) == count($_POST['candy'])){
  3.     for($i=0; $i<count($_POST['foo']); $i++){
  4.         echo 'foo: ' . $_POST['foo'][$i]
  5.              . ' bar: ' . 'bar: ' . $_POST['bar'][$i]
  6.              . 'candy: ' . $_POST['candy'][$i]
  7.              . '<br />';
  8.     }
  9. }
__________________
Verifica antes de preguntar.
Los verdaderos amigos se hieren con la verdad, para no perderlos con la mentira. - Eugenio Maria de Hostos