I have this while where I created a variable before the while to get the total of a column:
$Total = 0;
while($rows_cursos = mysqli_fetch_array($resultado_cursos)) {
$teste = $rows_cursos['Horas Consumidas'];
$Total = $Total + $teste;
$tabela3 .= '<tr>';
$tabela3 .= '<td>'.$rows_cursos['DataRegisto'].'</td>';
$tabela3 .= '<td>'.$rows_cursos['codigoutente'].'</td>';
$tabela3 .= '<td>'.$rows_cursos['nome'].'</td>';
$tabela3 .= '<td>'.$rows_cursos['descricaovalencia'].'</td>';
$tabela3 .= '<td>'.$rows_cursos['Data'].'</td>';
$tabela3 .= '<td>'.$rows_cursos['Inicio'].'</td>';
$tabela3 .= '<td>'.$rows_cursos['Fim'].'</td>';
$tabela3 .= '<td>'.$rows_cursos['Colaborador'].'</td>';
$tabela3 .= '<td>'.$rows_cursos['Horas Consumidas'].'</td>';
$tabela3 .= '</tr>';
}
$tabela3 .= '</tr>';
$tabela3 .='</tbody>';
$tabela3 .= '</table>';
$tabela3 .= '</div>';
echo $tabela3;
echo '<strong>Total de Horas Consumidas:</strong> '. $Total;
But this result that appears surrounded by red, wanted it to appear under the last column of the table as the arrow points, since it is the sum of the hours in that column.