0
I wonder if it is possible to Add a Table
HTML
within another table in a foreach
.
Explanation why I need this: I have the budgets in the database and each budget can have many composition items. I would like to list the composition items below their respective budgets.
I’m trying but the layout is breaking.
<table border="1">
<thead>
<tr>
<th>Item</th>
<th>Descricao</th>
<th>Quantidade</th>
<th>Valor unidade</th>
<th>Valor total</th>
<th>Cliente</th>
</tr>
</thead>
<tbody>
<?php $itemCount = 1 ?>
<?php foreach ($orcamentos->findAll() as $orcamento) : ?>
<tr>
<td>Item <?= $itemCount ?></td>
<td><?= $orcamento['descricao'] ?></td>
<td><?= $orcamento['quantidade'] ?></td>
<td><?= $orcamento['valor_unidade'] ?></td>
<td><?= $orcamento['valor_total'] ?></td>
<td><?= $clientes->where('id', $orcamento['cliente_id'])->first()['nome_cliente'] ?></td>
<td>
<table border="2">
<thead>
<tr>
<th>Item</th>
<th>Descricao</th>
<th>Quantidade</th>
<th>Valor unidade</th>
<th>Valor total</th>
<th>Fornecedor</th>
</tr>
</thead>
<tbody>
<tr>
<td>A</td>
<td>A</td>
<td>A</td>
<td>A</td>
<td>A</td>
<td>A</td>
</tr>
</tbody>
</table>
</td>
</tr>
<?php $itemCount += 1 ?>
<?php endforeach; ?>
</tbody>
</table>
yes it is possible, but the way it is in your code, to nest a
<table>
within the<tbody>
no, it can be nestled inside a<td>
. Create a<td>
and insert the table there, use colspan if necessary– Ricardo Pontual
He sided with each other.... @Ricardopunctual
– Boi Programador
can you put the code in the question? ai da para entender melhor
– Ricardo Pontual
@Ricardopunctual, I edited the question with the updated code...
– Boi Programador
there will be next to it, would be better to do in a line below, see this example I put together, if you want put in a reply: https://jsfiddle.net/4hrcz01w/1/
– Ricardo Pontual
@Ricardopunctual, worked, puts as an answer for me to score aushuash <3
– Boi Programador