How to mount dynamic horizontal table

0

I need to make a horizontal table that contains the months revenue and expenses, but I need to always calculate from the previous month, but the first month will not have the calculation.

Here is an example of how my code is.

$tabela = '<table width="100%" border="1"  cellspacing="0" cellpadding="2" style="text-align:left; font-size: 15px">';//abre table
$tabela .='<thead>';//abre cabeçalho
$tabela .= '<tr style="text-align: center; font-weight: bold">';//abre uma linha
$tabela .= '<td style="background-color: #5386B6;font-weight:bold; color: #FFFFFF">Metricas</td>'; // colunas do cabeçalho
foreach ($campo as $campos){
$tabela .= '<td>'.$campos['DATA_INICIO']. ' - '. $campos['DATA_FIM'].'</td>';
}
$tabela .= '</tr>';//fecha linha

$tabela .= '<tr style="text-align: center; ">';//abre uma linha
$tabela .= '<td style="background-color: #5386B6;font-weight:bold; color: #FFFFFF">Receita</td>'; // colunas do cabeçalho
foreach ($campo as $campos){
    $tabela .= '<td>'.$campos['ENTRADAS'].'</td>';
}
$tabela .= '</tr>';//fecha linha

$tabela .= '<tr style="text-align: center;">';//abre uma linha
$tabela .= '<td style="background-color: #5386B6;font-weight:bold; color: #FFFFFF">Despesas</td>'; // colunas do cabeçalho
foreach ($campo as $campos){
    $tabela .= '<td>'.$campos['SAIDAS'].'</td>';
}
$tabela .= '</tr>';//fecha linha

$tabela .='</thead>'; //fecha cabeçalho
$tabela .='<tbody>';//abre corpo da tabela

echo $tabela

and it goes like this

Ineedtoaddonemorefieldtoknowthepercentagechange,butintheexample,Januaryshouldnotcalculatewithanyone.

    
asked by anonymous 29.11.2018 / 20:59

0 answers