Ver Mensaje Individual
  #6 (permalink)  
Antiguo 17/03/2012, 18:50
Avatar de Nemutagk
Nemutagk
Colaborador
 
Fecha de Ingreso: marzo-2004
Ubicación: México
Mensajes: 2.633
Antigüedad: 20 años, 1 mes
Puntos: 406
Respuesta: Consultar datos de un array

o.O mmm se puede hacer mucho mejor!

formulario
Código HTML:
Ver original
  1. <input type="text" name="dato[]" />
  2. <input type="text" name="dato[]" />
  3. <input type="text" name="dato[]" />
  4. <input type="text" name="dato[]" />
  5. <input type="text" name="dato[]" />
  6. <input type="text" name="dato[]" />
  7. <input type="text" name="dato[]" />
  8. <input type="text" name="dato[]" />
  9. <!-- Y así todos los campos que necesites -->

PHP
Código PHP:
Ver original
  1. $sql = 'select * from mitabla where id in('.implode(',',$_POST['dato']).')';

Pero tu problema es que hay campos que están vacíos, tendrás que hacer algo así...
Código PHP:
Ver original
  1. $newArray = array();
  2. foreach($_POST['dato'] as $item) {
  3.      if (!empty($item)) {
  4.           $newArray[] = $item;
  5.      }
  6. }
  7.  
  8. $sql = 'select * from mitabla where id in('.implode(',',$newArray).')';
__________________
Listo?, tendría que tener 60 puntos menos de IQ para considerarme listo!!!
-- Sheldon Cooper
http://twitter.com/nemutagk
PD: No contestaré temas vía mensaje personal =)