Foros del Web » Programando para Internet » PHP »

[SOLUCIONADO] crear un bucle para leer varios registros en html

Estas en el tema de crear un bucle para leer varios registros en html en el foro de PHP en Foros del Web. Hola buenas estoy en una parte de webservice la cual me lee unas tablas con varios registros Forma grafica: http://postimg.org/image/956v9el2t bien pues leo un webservice ...
  #1 (permalink)  
Antiguo 10/11/2015, 10:08
 
Fecha de Ingreso: febrero-2011
Ubicación: Barcelona
Mensajes: 195
Antigüedad: 13 años
Puntos: 1
crear un bucle para leer varios registros en html

Hola buenas
estoy en una parte de webservice la cual me lee unas tablas con varios registros
Forma grafica:
http://postimg.org/image/956v9el2t

bien pues leo un webservice el cual me da dos linea sde registros pero en el php solo se me mestra una y si vuelvo a repetir las tablas me pinta la primera solo
Código PHP:
Ver original
  1. define('USERPWD', 'echidna\jconesa:jconesa');
  2. $empresa = '1 TPS-N_LAB';
  3. $baseURL = 'http://128.20.1.1:7047/DynamicsNAV/WS/';
  4. $pageURL = $baseURL.rawurlencode($empresa).'/Page/WTADistribucionesPorAutoriz';
  5. $NumCliente = '101222';  // deixar en blanc perque pregunti
  6.  
  7.  
  8. //-------------------------------------------------------------------------------------------------
  9. include("NTLMStream.php");  
  10. include("NTLMSoapClient.php");
  11.  
  12. // we unregister the current HTTP wrapper
  13. stream_wrapper_unregister('http');
  14. // we register the new HTTP wrapper
  15. stream_wrapper_register('http', 'NTLMStream') or die("Fallo al registrar protocolo");
  16.  
  17. // Initialize Page Soap Client
  18. $page = new NTLMSoapClient($pageURL);
  19. //-------------------------------------------------------------------------------------------------
  20.  
  21. /* if ($NumCliente == ''){
  22.   echo 'NumCliente? '; 
  23.   $NumCliente = fgets(STDIN);
  24. }
  25. echo "NumCliente: " . $NumCliente . PHP_EOL; */
  26. echo $cliente;
  27.  
  28.  
  29. $timeIni = time();
  30.  
  31. $params = array('filter' => array(
  32.                                     array('Field' => 'Cliente',
  33.                                           'Criteria' => $cliente)
  34.                                   ),
  35.                 'setSize' => 0);
  36. $result = $page->ReadMultiple($params);
  37. $distribuciones = $result->ReadMultiple_Result->WTADistribucionesPorAutoriz ;
  38.  
  39. /* echo 'Num_distribucion | Num_contrato | Cdad_disponible '; */
  40. //echo '| Cdad_existente'
  41. echo PHP_EOL;
  42. if (is_array($distribuciones)) {
  43.   foreach($distribuciones as $distrib) {
  44.    /*  echo $distrib->Num_distribucion . ' | ';
  45.     echo $distrib->Num_contrato . ' | ';
  46.     echo $distrib->Cdad_disponible ;
  47.     echo $distrib->Cdad_existente */
  48.        
  49.     echo PHP_EOL;
  50.    
  51.   }    
  52. }
  53. /* else {
  54.   echo $distribuciones->Num_distribución . PHP_EOL;
  55. }  */
  56. $ndistri = $distrib->Num_autorizacion;
  57. $clientes = $distrib->Cliente;
  58. $matriculat = $distrib->Matricula_tractora;
  59. $matricular = $distrib->Matricula_remolque;
  60. $dni = $distrib->DNI_conductor;
  61. $namedriver = $distrib->Nombre_conductor;
  62. $fecha = $distrib->Fecha;
  63. $hora = $distrib->Hora;
  64. $estado = $distrib->Estado;
  65. $contrato = $distrib->Contrato;
  66.  
  67. /* echo $ndistri. ' | ';
  68. echo $cliente. ' | ';
  69. echo $matriculat. ' | ';
  70. echo $matricular. ' | ';
  71. echo $dni. ' | ';
  72. echo $namedriver. ' | ';
  73. echo $fecha. ' | ';
  74. echo $hora. ' | ';
  75. echo $estado. ' | '; */
  76. //sleep(3);
  77. echo 'Respuesta en ';
  78. echo  time() - $timeIni . ' segundos' ;
  79. ?>
  80.  
  81. <table class="table table-bordered table-striped datatable" id="table-2">
  82.     <thead>
  83.         <tr>
  84.             <th>
  85.                 <div class="checkbox checkbox-replace">
  86.                     <input type="checkbox" id="chk-1">
  87.                 </div>
  88.             </th>
  89.             <th>Contrato</th>                                        
  90.             <th>Cliente</th>                                              
  91.             <th>Matricula Tractora</th>                            
  92.             <th>DNI PASAPORTE</th>                              
  93.             <th>Matricula Remolque</th>                          
  94.             <th>Nombre</th>                                            
  95.         </tr>
  96.     </thead>
  97.    
  98.     <tbody>
  99.         <tr>
  100.             <td>
  101.                 <div class="checkbox checkbox-replace">
  102.                     <input type="checkbox" id="chk-1">
  103.                 </div>
  104.             </td>
  105.             <td><?php echo $contrato;?></td>   <------------------------
  106.             <td><?php echo $clientes;?></td>     <-----------------------
  107.             <td><?php echo $matriculat;?></td> <----------------------
  108.             <td><?php echo $dni;?></td> <-------------------------------
  109.             <td><?php echo $matricular;?></td><-----------------------
  110.             <td><?php echo $namedriver;?></td><----------------------
  111.             <td>
  112.                 <a href="#" class="btn btn-default btn-sm btn-icon icon-left">
  113.                     <i class="entypo-pencil"></i>
  114.                     Edit
  115.                 </a>
  116.                
  117.                 <a href="#" class="btn btn-danger btn-sm btn-icon icon-left">
  118.                     <i class="entypo-cancel"></i>
  119.                     Delete
  120.                 </a>
  121.                
  122.                 <a href="#" class="btn btn-info btn-sm btn-icon icon-left">
  123.                     <i class="entypo-info"></i>
  124.                     Profile
  125.                 </a>
  126.             </td>
  127.         </tr>

bueno buscando creo que me extendido , seria hacer un foreach para crear las tablas exactamente donde indico.

Última edición por javierconesa23; 10/11/2015 a las 10:42
  #2 (permalink)  
Antiguo 10/11/2015, 11:52
Avatar de mortiprogramador
Colaborador
 
Fecha de Ingreso: septiembre-2009
Ubicación: mortuoria
Mensajes: 3.805
Antigüedad: 14 años, 6 meses
Puntos: 214
Respuesta: crear un bucle para leer varios registros en html

Saludo
Pues basta con bajar el foreach que ya se tiene
a la parte del tr donde se van a dibujar los
respectivos td, y en el foreach hacer ese dibujado de los td.

Así, incluso sí solo tiene uno o varios registros, serán dibujados.
Adicionalmente, poner un if antes del foreach en caso que el size
de la variable de resultados sea 0, para que no entre al ciclo,
de otra manera, dará un warning porque no tiene elementos para recorrer.
__________________
"Si consigues ser algo más que un hombre, si te entregas a un ideal, si nadie puede detenerte, te conviertes en algo muy diferente."
Visita piggypon.com
  #3 (permalink)  
Antiguo 11/11/2015, 03:48
 
Fecha de Ingreso: febrero-2011
Ubicación: Barcelona
Mensajes: 195
Antigüedad: 13 años
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)
  #4 (permalink)  
Antiguo 11/11/2015, 03:52
 
Fecha de Ingreso: febrero-2011
Ubicación: Barcelona
Mensajes: 195
Antigüedad: 13 años
Puntos: 1
Respuesta: crear un bucle para leer varios registros en html

eso que comento con este codigo:
Código PHP:
Ver original
  1. echo '<table class="table table-bordered table-striped datatable" id="table-2">';
  2. echo    '<thead>';
  3. echo        '<tr>';
  4. echo            '<th>';
  5. echo                '<div class="checkbox checkbox-replace">';
  6. echo                    '<input type="checkbox" id="chk-1">';
  7. echo                '</div>';
  8. echo            '</th>';
  9. echo            '<th>Contrato</th>';
  10. echo            '<th>Cliente</th>';
  11. echo            '<th>Cupo</th>';
  12. echo            '<th>Matricula</th>';
  13. echo            '<th>DNI PASAPORTE</th>';
  14. echo            '<th>Matricula</th>';
  15. echo            '<th>Nombre</th>';
  16. echo        '</tr>';
  17. echo    '</thead>';
  18.    
  19. echo    '<tbody>';
  20. echo        '<tr>';
  21. echo            '<td>';
  22. echo                '<div class="checkbox checkbox-replace">';
  23. echo                    '<input type="checkbox" id="chk-1">';
  24. echo                '</div>';
  25. echo            '</td>';
  26. echo            '<td>Randy S. Smith</td>';
  27. echo            '<td>8.7</td>';
  28. echo            '<td>Social and human service</td>';
  29. echo            '<td>';
  30. echo                '<a href="#" class="btn btn-default btn-sm btn-icon icon-left">';
  31. echo                    '<i class="entypo-pencil"></i>';
  32. echo                    'Edit';
  33. echo                '</a>';
  34.                
  35. echo                '<a href="#" class="btn btn-danger btn-sm btn-icon icon-left">';
  36. echo                    '<i class="entypo-cancel"></i>';
  37. echo                    'Delete';
  38. echo                '</a>';
  39.                
  40. echo                '<a href="#" class="btn btn-info btn-sm btn-icon icon-left">';
  41. echo                    '<i class="entypo-info"></i>';
  42. echo                    'Profile';
  43. echo                '</a>';
  44. echo            '</td>';
  45. echo        '</tr>';
  46.        
  47. echo        '<tr>';
  48. echo            '<td>';
  49. echo                '<div class="checkbox checkbox-replace">';
  50. echo                    '<input type="checkbox" id="chk-1">';
  51. echo                '</div>';
  52. echo            '</td>';

Melo pinta si

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 segundos

Contrato Cliente Cupo Matricula DNI PASAPORTE Matricula Nombre

Randy S. Smith 8.7 Social and human service EditDeleteProfile


entonces pienso tengo que montar las tablas fuera del php para que me lo ejecute antes pero me doy cuenta que fuera del php como aun no ha leido el foreach , no puedo montar el resultado dentro de la tsabla


Espero puedas ayudarme
GRacias
  #5 (permalink)  
Antiguo 11/11/2015, 04:08
Avatar de mortiprogramador
Colaborador
 
Fecha de Ingreso: septiembre-2009
Ubicación: mortuoria
Mensajes: 3.805
Antigüedad: 14 años, 6 meses
Puntos: 214
Respuesta: crear un bucle para leer varios registros en html

Saludo
Pues yo me refería era a poner el foreach luego de los títulos de la tabla,
pero lo que veo es que se dejó toda la creación de la tabla
dentro del foreach, y por eso es que repite tantas veces
como registros haya.

Así que, retomando la respuesta anterior, el asunto es llevar el foreach
a la parte donde se deben mostrar los resultados, sin involucrar
a la totalidad de la tabla, solamente los tr que se van a dibujar
luego de dibujar los títulos de las columnas de la tabla.

Es decir

Código PHP:
Ver original
  1. <table class="table table-bordered table-striped datatable" id="table-2">
  2.     <thead>
  3.         <tr>
  4.             <th>
  5.                 <div class="checkbox checkbox-replace">
  6.                     <input type="checkbox" id="chk-1">
  7.                 </div>
  8.             </th>
  9.             <th>Contrato</th>                                        
  10.             <th>Cliente</th>                                              
  11.             <th>Matricula Tractora</th>                            
  12.             <th>DNI PASAPORTE</th>                              
  13.             <th>Matricula Remolque</th>                          
  14.             <th>Nombre</th>                                            
  15.         </tr>
  16.     </thead>
  17.    
  18.  //aqui el foreach
  19. if (is_array($distribuciones)) {
  20.   foreach($distribuciones as $distrib) {
  21.    echo ' <tbody>
  22.        <tr>
  23.            <td>
  24.                <div class="checkbox checkbox-replace">
  25.                    <input type="checkbox" id="chk-1">
  26.                </div>
  27.            </td>
  28.            <td>'.$distrib->Contrato.'</td>   <------------------------
  29.            <td>
  30.                <a href="#" class="btn btn-default btn-sm btn-icon icon-left">
  31.                    <i class="entypo-pencil"></i>
  32.                    Edit
  33.                </a>
  34.                
  35.                <a href="#" class="btn btn-danger btn-sm btn-icon icon-left">
  36.                    <i class="entypo-cancel"></i>
  37.                    Delete
  38.                </a>
  39.                
  40.                <a href="#" class="btn btn-info btn-sm btn-icon icon-left">
  41.                    <i class="entypo-info"></i>
  42.                    Profile
  43.                </a>
  44.            </td>
  45.        </tr>';
  46.   }    
  47. }
__________________
"Si consigues ser algo más que un hombre, si te entregas a un ideal, si nadie puede detenerte, te conviertes en algo muy diferente."
Visita piggypon.com
  #6 (permalink)  
Antiguo 11/11/2015, 04:21
 
Fecha de Ingreso: febrero-2011
Ubicación: Barcelona
Mensajes: 195
Antigüedad: 13 años
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
  #7 (permalink)  
Antiguo 11/11/2015, 04:23
Avatar de mortiprogramador
Colaborador
 
Fecha de Ingreso: septiembre-2009
Ubicación: mortuoria
Mensajes: 3.805
Antigüedad: 14 años, 6 meses
Puntos: 214
Respuesta: crear un bucle para leer varios registros en html

Cerca.
Fijate el ejemplo que te puse, y como dibujo el contrato.
__________________
"Si consigues ser algo más que un hombre, si te entregas a un ideal, si nadie puede detenerte, te conviertes en algo muy diferente."
Visita piggypon.com
  #8 (permalink)  
Antiguo 11/11/2015, 04:56
 
Fecha de Ingreso: febrero-2011
Ubicación: Barcelona
Mensajes: 195
Antigüedad: 13 años
Puntos: 1
Respuesta: crear un bucle para leer varios registros en html

Ok Gracias!!!! perfecto
Código PHP:
Ver original
  1. echo '<table class="table table-bordered table-striped datatable" id="table-2">';
  2. echo    '<thead>';
  3. echo        '<tr>';
  4. echo            '<th>';
  5. echo                '<div class="checkbox checkbox-replace">';
  6. echo                    '<input type="checkbox" id="chk-1">';
  7. echo                '</div>';
  8. echo            '</th>';
  9. echo            '<th>Contrato</th>';
  10. echo            '<th>Cliente</th>';
  11. echo            '<th>Matricula</th>';
  12. echo            '<th>DNI PASAPORTE</th>';
  13. echo            '<th>Matricula Remolque</th>';
  14. echo            '<th>Nombre</th>';
  15. echo        '</tr>';
  16. echo    '</thead>';
  17. if (is_array($distribuciones)) {
  18.   foreach($distribuciones as $distrib) {
  19.    echo ' <tbody>
  20.        <tr>
  21.            <td>
  22.                <div class="checkbox checkbox-replace">
  23.                    <input type="checkbox" id="chk-1">
  24.                </div>
  25.            </td>
  26.            <td>'.$distrib->Contrato.'</td>
  27.             <td>'.$distrib->Cliente.'</td>
  28.             <td>'.$distrib->Matricula_tractora.'</td>
  29.             <td>'.$distrib->DNI_conductor.'</td>
  30.             <td>'.$distrib->Matricula_remolque.'</td>
  31.             <td>'.$distrib->Nombre_conductor.'</td>
  32.            <td>
  33.                <a href="#" class="btn btn-default btn-sm btn-icon icon-left">
  34.                    <i class="entypo-pencil"></i>
  35.                    Edit
  36.                </a>
  37.                
  38.                <a href="#" class="btn btn-danger btn-sm btn-icon icon-left">
  39.                    <i class="entypo-cancel"></i>
  40.                    Delete
  41.                </a>
  42.                
  43.                <a href="#" class="btn btn-info btn-sm btn-icon icon-left">
  44.                    <i class="entypo-info"></i>
  45.                    Profile
  46.                </a>
  47.            </td>
  48.        </tr>';
  49.   }    
  50. }
  51.  
  52. ?>


Pero una ultima pregunta porque si n despues del primer foreach cambio a variables mas cortas con:
Código PHP:
Ver original
  1. $ndistri = $distrib->Num_autorizacion;
  2. $clientes = $distrib->Cliente;
  3. $matriculat = $distrib->Matricula_tractora;
  4. $matricular = $distrib->Matricula_remolque;
  5. $dni = $distrib->DNI_conductor;
  6. $namedriver = $distrib->Nombre_conductor;
  7. $fecha = $distrib->Fecha;
  8. $hora = $distrib->Hora;
  9. $estado = $distrib->Estado;
  10. $contrato = $distrib->Contrato;

y si llamo alos contratos por la variable corta me 3 registros del mismo contrato
Ej con: $distrib->Contrato
Contrato Cliente Matricula DNI PASAPORTE Matricula Remolque Nombre

80317048-10 47564 4764 AFR 39654225L 5567 CFG Pere Vilagran Edit Delete Profile

80317048-10 47564 4764 AFR 39654225L 5567 CFG Pere Vilagran Edit Delete Profile

80317048-11 47564 4764 AFR 39654225L 5567 CFG Pere Vilagran Edit Delete Profile

Ejemplo con $contrato:
Contrato Cliente Matricula DNI PASAPORTE Matricula Remolque Nombre

80317048-11 47564 4764 AFR 39654225L 5567 CFG Pere Vilagran Edit Delete Profile

80317048-11 47564 4764 AFR 39654225L 5567 CFG Pere Vilagran Edit Delete Profile

80317048-11 47564 4764 AFR 39654225L 5567 CFG Pere Vilagran Edit Delete Profile




Gracias de todas formas por tu ayuda prestada:
  #9 (permalink)  
Antiguo 11/11/2015, 17:43
Avatar de mortiprogramador
Colaborador
 
Fecha de Ingreso: septiembre-2009
Ubicación: mortuoria
Mensajes: 3.805
Antigüedad: 14 años, 6 meses
Puntos: 214
Respuesta: crear un bucle para leer varios registros en html

Saludo
Eso es porque esas variables solo toman un solo valor,
no están en el ciclo.

Se podría , dentro del foreach, dejar esas variables,
y a su vez usar esas variables en los respectivos td.

Algo así

foreach distribuciones as distrib
...variable1 es distrib del contrato
...variable2 es distrib del nombre
.....td con variable1
.....td con variable2
findelforeach
__________________
"Si consigues ser algo más que un hombre, si te entregas a un ideal, si nadie puede detenerte, te conviertes en algo muy diferente."
Visita piggypon.com

Etiquetas: fecha, registro, registros, tabla, webservice
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 01:56.