php - Array line break

-1

I want to skip a row in a table, but I can not figure out a logic to do this. I tried the explode and I did not succeed.

<td><?=$teste['cod_refugo_teste'];?></td>
<td><?=$teste['qtd_refugo']; ?></td>

The code looks like this:

I want the scrap and quantity lines to break, but I can not find a way to do it.

    
asked by anonymous 17.09.2018 / 13:34

2 answers

0

You need to use the rowspan attribute in the tag.

Here is an example of exactly what behavior you want: link

    
18.09.2018 / 20:17
-1

Silvia, in that case it would be more interesting to see your complete code to understand what is inside the $teste variable.

The HTML tag for skipping lines is the <tr></tr> that creates a new line. For each new line, a <tr></tr> must be added.

If the values of the $teste are in an array, you can create a loop function, such as for , for example:

<?php

$valores = [
    'produto1',
    'quantidade1',
    'responsavel1',
    'data1',
    'produto1',
    'quantidade2',
    'responsavel2',
    'data2'
];

$html = "";

for ($n = 0 ; $n < count($valores) ; $n++) {
    if ($n % 3 == 0 || $n == 0)
        html += "<tr>";

    html += $valores[$n];

    if($n % 3 == 0 || $n == 0)
        html += "</tr>";
}
    
17.09.2018 / 15:26