-1
But I wanted the total value in a single cell not to be separated into several total values. Exp:
Date|Name|value
2020-02-12|a|1.00€
2020-02-12|b|1.00€
Total Value|2.00€
Code:
<table style="width: 50%;" border='0' id="table" name="table">
<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>
<?php
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>");
}
if($registo['valor']){
?>
<tr>
<td align='left' colspan='2' bgcolor='#baba84'><b>Valor Total</b></td>
<?php
$valor_total=0;
$valor_total = $valor_total+$registo['valor'];
if($valor_total>=$valor_total.".00"){
$valor_t=$valor_total.".00";
?>
<td align='left' bgcolor='white'><?php echo $valor_t."€"?></td>
<?php
}
else{
?>
<td align='left' bgcolor='white'><?php echo $valor_total."€"?></td>
<?php
}
echo "</tr>";
}
echo "</tr>";
}
?>
</table>
You could help me identify the mistake I’m making to make the chart look like this.
Try to talk better about what you need, you’re very confused...
– Jakson Fischer
@Jaksonfischer already made an example
– Bruno Teixeira
You’re a little confused, could exemplify better?
– Mateus Daniel
@Mateusd. exemplify how I made an example how I want the table
– Bruno Teixeira