Unir dos foreach
Publicado por Fran (8 intervenciones) el 23/06/2019 21:52:00
Tengo dos códigos, uno para crear usuarios y otro para kardex. ¿Cómo puedo hacer para que salga todo en una sola tabla?.
1. Código de los usuarios con los siguientes datos:
2. Código para el kardex con los siguientes datos:
Muchas gracias
1. Código de los usuarios con los siguientes datos:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php $users = PersonData::getClients();
if(count($users)>0){
// si hay usuarios
?>
<table class="table table-bordered table-hover">
<thead>
<th>Nombre </th>
<th>Dirección</th>
<th>NIT o DUI</th>
<th></th>
<th>Alumno</th>
<th>Grado y Sección</th>
<th></th>
<th>Factura</th>
<th>Total</th>
<th>Motivo</th>
</thead>
<?php
foreach($users as $user){
?>
<tr>
<td><?php echo $user->name;?></td>
<td><?php echo $user->phone2; ?></td>
<td><?php echo $user->address2; ?></td>
<td></td>
<td><?php echo $user->lastname;?></td>
<td><?php echo $user->address1; ?></td>
<td></td>
<td><?php echo $user->email2; ?></td>
<td><?php echo $user->email1; ?></td>
<td><?php echo $user->phone1; ?></td>
<td style="width:130px;">
<a href="index.php?view=editclient&id=<?php echo $user->id;?>" class="btn btn-warning btn-xs">Editar</a>
<a href="index.php?view=delclient&id=<?php echo $user->id;?>" class="btn btn-danger btn-xs">Eliminar</a>
</td>
</tr>
<?php
}
}else{
echo "<p class='alert alert-danger'>No has registrado todavía ningún cliente.</p>";
}
?>
2. Código para el kardex con los siguientes datos:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php $products = ProductData::getAll();?>
<?php if(count($operations)>0):?>
<table class="table table-bordered">
<thead>
<th>Fecha</th>
<th>Factura</th>
<th>Cliente</th>
<th>Nacionalidad</th>
<th>Producto</th>
<th>Unidad</th>
<th>Operacion</th>
<th>Cantidad</th>
<th>Precio</th>
</thead>
<?php foreach($operations as $operation):?>
<tr>
<td><?php echo $operation->created_at; ?></td>
<td> <?php echo $operation->email1; ?></td>
<td> <?php echo $operation->name; ?></td>
<td> El Salvador</td>
<td><?php echo $operation->getProduct()->name; ?></td>
<td> c/u </td>
<td><?php echo $operation->getOperationType()->name; ?></td>
<td><?php echo $operation->q; ?></td>
<td>$ <?php echo $operation->getProduct()->price_in; ?></td>
</tr>
<?php endforeach; ?>
</table>
<?php else:
// si no hay operaciones
?>
Muchas gracias
Valora esta pregunta
0