Ver Mensaje Individual
  #3 (permalink)  
Antiguo 11/11/2015, 03:48
javierconesa23
 
Fecha de Ingreso: febrero-2011
Ubicación: Barcelona
Mensajes: 195
Antigüedad: 13 años, 2 meses
Puntos: 1
Respuesta: crear un bucle para leer varios registros en html

Hola buenas, gracias por responder..
he hecho lo que me has dicho pero falla algo, el registro original sale asi
NumCliente: 47564
3 | 47564 | 126 | 80317048-10 | 4764 AFR | 39654225L | 2015-11-04 | 09:00:00.0000000 | Confirmada |
4 | 47564 | 126 | 80317048-10 | 4764 AFR | 39654225L | 2015-11-05 | 09:00:00.0000000 | Confirmada |
4 | 47564 | 126 | 80317048-11 | 4764 AFR | 39654225L | 2015-11-05 | 09:00:00.0000000 | Confirmada |
para ello uso este codigo:
Código PHP:
Ver original
  1. if ($NumCliente == ''){
  2.   echo 'NumCliente? '; 
  3.   $NumCliente = fgets(STDIN);
  4. }
  5. echo "NumCliente: " . $NumCliente . PHP_EOL;
  6.  
  7. $timeIni = time();
  8.  
  9. $params = array('filter' => array(
  10.                                     array('Field' => 'Cliente',
  11.                                           'Criteria' => $NumCliente)
  12.                                   ),
  13.                 'setSize' => 0);
  14. $result = $page->ReadMultiple($params);
  15. $distribuciones = $result->ReadMultiple_Result->WTADistribucionesPorAutoriz;
  16.  
  17. echo 'Num_autorizacion | Cliente | Matricula_tractora | DNI_conductor | Fecha | Hora | Estado | Producto';
  18. echo '<br>';
  19. echo PHP_EOL;
  20. if (is_array($distribuciones)) {
  21.   foreach($distribuciones as $distrib) {
  22.     echo $distrib->Num_autorizacion . ' | ';
  23.     echo $distrib->Cliente . ' | ';
  24.     echo $distrib->Contrato. ' | ';
  25.     echo $distrib->Matricula_tractora . ' | ';
  26.     echo $distrib->DNI_conductor . ' | ';
  27.     echo $distrib->Fecha . ' | ';
  28.     echo $distrib->Hora . ' | ';
  29.     echo $distrib->Estado . ' | ';
  30.     echo $distrib->Producto ;
  31.     echo '<br>';
  32.     echo PHP_EOL;
  33.   }
  34. }
  35. else {
  36.   echo $distribuciones->Num_autorizacion . PHP_EOL;
  37. }
  38.  
  39. //sleep(3);
  40. echo 'Respuesta en ';
  41. echo  time() - $timeIni . ' segundos' ;
  42. ?>


Pero en cuanto pongo las tablas me pasan dos cosas, si la meto dentro del foreac merepite las tablas tantas veces como registros tenga:
Código PHP:
Ver original
  1. if (is_array($distribuciones)) {
  2.  
  3.   foreach($distribuciones as $distrib) {
  4. echo '<table class="table table-bordered table-striped datatable" id="table-2">';
  5. echo    '<thead>';
  6. echo        '<tr>';
  7. echo            '<th>';
  8. echo                '<div class="checkbox checkbox-replace">';
  9. echo                    '<input type="checkbox" id="chk-1">';
  10. echo                '</div>';
  11. echo            '</th>';
  12. echo            '<th>Contrato</th>';
  13. echo            '<th>Cliente</th>';
  14. echo            '<th>Cupo</th>';
  15. echo            '<th>Matricula</th>';
  16. echo            '<th>DNI PASAPORTE</th>';
  17. echo            '<th>Matricula</th>';
  18. echo            '<th>Nombre</th>';
  19. echo        '</tr>';
  20. echo    '</thead>';
  21.    
  22. echo    '<tbody>';
  23. echo        '<tr>';
  24. echo            '<td>';
  25. echo                '<div class="checkbox checkbox-replace">';
  26. echo                    '<input type="checkbox" id="chk-1">';
  27. echo                '</div>';
  28. echo            '</td>';
  29. echo            '<td>Randy S. Smith</td>';
  30. echo            '<td>8.7</td>';
  31. echo            '<td>Social and human service</td>';
  32. echo            '<td>';
  33. echo                '<a href="#" class="btn btn-default btn-sm btn-icon icon-left">';
  34. echo                    '<i class="entypo-pencil"></i>';
  35. echo                    'Edit';
  36. echo                '</a>';
  37.                
  38. echo                '<a href="#" class="btn btn-danger btn-sm btn-icon icon-left">';
  39. echo                    '<i class="entypo-cancel"></i>';
  40. echo                    'Delete';
  41. echo                '</a>';
  42.                
  43. echo                '<a href="#" class="btn btn-info btn-sm btn-icon icon-left">';
  44. echo                    '<i class="entypo-info"></i>';
  45. echo                    'Profile';
  46. echo                '</a>';
  47. echo            '</td>';
  48. echo        '</tr>';
  49.        
  50. echo        '<tr>';
  51. echo            '<td>';
  52. echo                '<div class="checkbox checkbox-replace">';
  53. echo                    '<input type="checkbox" id="chk-1">';
  54. echo                '</div>';
  55. echo            '</td>';
  56.     echo $distrib->Num_autorizacion . ' | ';
  57.     echo $distrib->Cliente . ' | ';
  58.     echo $distrib->Contrato. ' | ';
  59.     echo $distrib->Matricula_tractora . ' | ';
  60.     echo $distrib->DNI_conductor . ' | ';
  61.     echo $distrib->Fecha . ' | ';
  62.     echo $distrib->Hora . ' | ';
  63.     echo $distrib->Estado . ' | ';
  64.     echo $distrib->Producto ;
  65.     echo '<br>';
  66.     echo PHP_EOL;
  67.   }
  68. }
  69. else {
  70.   echo $distribuciones->Num_autorizacion . PHP_EOL;
  71. }
  72.  
  73. //sleep(3);
  74. echo 'Respuesta en ';
  75. echo  time() - $timeIni . ' segundos' ;
  76. ?>
esto me monta esto:
NumCliente: 47564
3 | 47564 | 80317048-10 | 4764 AFR | 39654225L | 2015-11-04 | 09:00:00.0000000 | Confirmada | 126

Contrato Cliente Cupo Matricula DNI PASAPORTE Matricula Nombre

Randy S. Smith 8.7 Social and human service EditDeleteProfile

4 | 47564 | 80317048-10 | 4764 AFR | 39654225L | 2015-11-05 | 09:00:00.0000000 | Confirmada | 126

Contrato Cliente Cupo Matricula DNI PASAPORTE Matricula Nombre

Randy S. Smith 8.7 Social and human service EditDeleteProfile

4 | 47564 | 80317048-11 | 4764 AFR | 39654225L | 2015-11-05 | 09:00:00.0000000 | Confirmada | 126
Respuesta en 0 segundos

Contrato Cliente Cupo Matricula DNI PASAPORTE Matricula Nombre

Randy S. Smith 8.7 Social and human service EditDeleteProfile


Pero si la quito fuera del foreac me monta la tabla debajo de los resultados (COntinuo otro mensaje porque no cabe)