I have generated a list that is generated in the following way:
foreach ($productos as $p) {
echo '<tr>';
echo '<td>' . $p->codigoProducto . '</td>';
echo '<td>' . $p->categoriaNombre . '</td>';
echo '<td>' . $p->marcaNombre . '</td>';
echo '<td>' . $p->detalleProducto . '</td>';
echo '<td>' . $p->precioProducto . '</td>';
echo '</tr>';
}
As a category it is repeated, I would like to print it once only so that it remains
Categoria
Código | Marca | Detalle | Precio
1
2
3
...
But I can not call the value of the field outside the foreach
.