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

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: