-1
I wanted to separate my array by columns in a table. When I enter the records you get a ',' but when I take the comma you get an Array to string Conversion error. Could you help me?
How I wanted the table to stay:
Date|Name|Value
2020-01-02|a|1.00€
2020-01-02|b|1.00€
Total value| 2.00€
Here is my code:
<table style="width: 50%;" border='0' id="table" name="table">
<thead>
<tr>
<th width="10%" align='center' bgcolor='#baba84'>Data</th>
<th width="25%" align='center' bgcolor='#baba84'>Nome do custo</th>
<th width="8%" align='center' bgcolor='#baba84'>Valor</th>
</tr>
</thead>
<tbody>
<?php
$total_valor = 0;
while($registo = mysqli_fetch_assoc($resultado))
{
echo '<tr>';
echo'<td align="left" bgcolor="white">'.$registo['data'].'</td>';
echo'<td bgcolor="white">'. $registo['nome_custo'].'</td>';
if($registo['valor']>=$registo['valor'].".00"){
$valor=$registo['valor'].".00";
echo "<td align='left' bgcolor='white'>".$valor."€</td>";
print ("<td bgcolor='white' width='1%'><a href='alterar_custos.php?num={$registo['num']}&data={$registo['data']}&nome={$registo['nome_custo']}&valor=$valor' class='button2'>Ver</a></td>");
print ("<td bgcolor='white' width='1%'><a href='eliminar_custos.php?num={$registo['num']}' class='button2'>Eliminar</a></td>");
}
else{
echo "<td align='left' bgcolor='white'>".$registo['valor']."€></td>";
print ("<td bgcolor='white' width='1%'><a href='alterar_custos.php?num={$registo['num']}&data={$registo['data']}&nome={$registo['nome_custo']}&valor={$registo['valor']}' class='button2'>Ver</a></td>");
print ("<td bgcolor='white' width='1%'><a href='eliminar_custos.php?num={$registo['num']}' class='button2'>Eliminar</a></td>");
}
$total_valor += $registo['valor'];
}
?>
</tbody>
<tfoot>
<tr>
<td align='left' colspan='2' bgcolor='#baba84'><b>Valor Total</b></td>
<td align='left' bgcolor='white'><?php echo number_format($total_valor, 2, '.', '.')."€"; ?></td>
</tr>
</tfoot>
</table>