Ver Mensaje Individual
  #6 (permalink)  
Antiguo 11/11/2015, 04:21
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

Asi lo he heecho pero no me da registros completos solo el primero y lo repite tantas veces como registros hay.
Código PHP:
Ver original
  1. if (is_array($distribuciones)) {
  2.  
  3.   foreach($distribuciones as $distrib) {
  4.  
  5.     echo $distrib->Num_autorizacion . ' | ';
  6.     echo $distrib->Cliente . ' | ';
  7.     echo $distrib->Contrato. ' | ';
  8.     echo $distrib->Matricula_tractora . ' | ';
  9.     echo $distrib->DNI_conductor . ' | ';
  10.     echo $distrib->Fecha . ' | ';
  11.     echo $distrib->Hora . ' | ';
  12.     echo $distrib->Estado . ' | ';
  13.     echo $distrib->Producto ;
  14.     echo '<br>';
  15.     echo PHP_EOL;
  16.   }
  17. }
  18. $ndistri = $distrib->Num_autorizacion;
  19. $clientes = $distrib->Cliente;
  20. $matriculat = $distrib->Matricula_tractora;
  21. $matricular = $distrib->Matricula_remolque;
  22. $dni = $distrib->DNI_conductor;
  23. $namedriver = $distrib->Nombre_conductor;
  24. $fecha = $distrib->Fecha;
  25. $hora = $distrib->Hora;
  26. $estado = $distrib->Estado;
  27. $contrato = $distrib->Contrato;
  28. /* else {
  29.   echo $distribuciones->Num_autorizacion . PHP_EOL;
  30. }  */
  31.  
  32. //sleep(3);
  33. echo 'Respuesta en ';
  34. echo  time() - $timeIni . ' segundos' ;
  35. echo $distrib->Num_autorizacion;
  36. echo '<br>';
  37. echo PHP_EOL;
  38. echo '<table class="table table-bordered table-striped datatable" id="table-2">';
  39. echo    '<thead>';
  40. echo        '<tr>';
  41. echo            '<th>';
  42. echo                '<div class="checkbox checkbox-replace">';
  43. echo                    '<input type="checkbox" id="chk-1">';
  44. echo                '</div>';
  45. echo            '</th>';
  46. echo            '<th>Contrato</th>';
  47. echo            '<th>Cliente</th>';
  48. echo            '<th>Matricula</th>';
  49. echo            '<th>DNI PASAPORTE</th>';
  50. echo            '<th>Matricula Remolque</th>';
  51. echo            '<th>Nombre</th>';
  52. echo        '</tr>';
  53. echo    '</thead>';
  54.    
  55. echo    '<tbody>';
  56. echo        '<tr>';
  57. echo            '<td>';
  58. echo                '<div class="checkbox checkbox-replace">';
  59. echo                    '<input type="checkbox" id="chk-1">';
  60. echo                '</div>';
  61. echo            '</td>';
  62. if (is_array($distribuciones)) {
  63. foreach($distribuciones as $distrib) {
  64. echo            '<td>'.$contrato.'</td>';
  65. echo            '<td>'.$clientes.'</td>';
  66. echo            '<td>'.$matriculat.'</td>';
  67. echo            '<td>'.$dni.'</td>';
  68. echo            '<td>'.$matricular.'</td>';
  69. echo            '<td>'.$namedriver.'</td>';
  70.     }
  71. }
  72. echo            '<td>';
  73. echo                '<a href="#" class="btn btn-default btn-sm btn-icon icon-left">';
  74. echo                    '<i class="entypo-pencil"></i>';
  75. echo                    'Edit';
  76. echo                '</a>';
  77.                
  78. echo                '<a href="#" class="btn btn-danger btn-sm btn-icon icon-left">';
  79. echo                    '<i class="entypo-cancel"></i>';
  80. echo                    'Delete';
  81. echo                '</a>';
  82.                
  83. echo                '<a href="#" class="btn btn-info btn-sm btn-icon icon-left">';
  84. echo                    '<i class="entypo-info"></i>';
  85. echo                    'Profile';
  86. echo                '</a>';
  87. echo            '</td>';
  88. echo        '</tr>';
  89.        
  90. echo        '<tr>';
  91. echo            '<td>';
  92. echo                '<div class="checkbox checkbox-replace">';
  93. echo                    '<input type="checkbox" id="chk-1">';
  94. echo                '</div>';
  95. echo            '</td>';
  96. ?>

asi quedo:
NumCliente: 47564 3 | 47564 | 80317048-10 | 4764 AFR | 39654225L | 2015-11-04 | 09:00:00.0000000 | Confirmada | 126
4 | 47564 | 80317048-10 | 4764 AFR | 39654225L | 2015-11-05 | 09:00:00.0000000 | Confirmada | 126
4 | 47564 | 80317048-11 | 4764 AFR | 39654225L | 2015-11-05 | 09:00:00.0000000 | Confirmada | 126
Respuesta en 0 segundos4

Contrato Cliente Matricula DNI PASAPORTE Matricula Remolque Nombre

80317048-11 47564 4764 AFR 39654225L 5567 CFG Pere Vilagran 80317048-11 47564 4764 AFR 39654225L 5567 CFG Pere Vilagran 80317048-11 47564 4764 AFR 39654225L 5567 CFG Pere Vilagran EditDeleteProfile