[Resolvido] Tabela em loop
Estou fazendo um relatório e dividi o resultado do relatório por grupo. até aí tudo bem, está gerando separado por grupo, minha dúvida é o seguinte, como colocar o valor total de cada grupo?
Segue o exemplo de meu código.
<fieldset>
<legend>Relatório</legend>
<?php $nome_grupo = ''; ?>
<?php while($dados = $conexao->busca($sql)){ ?>
<?php if($nome_grupo != $dados['grupo']){ ?>
<legend><br><?php echo $dados['grupo']; ?></legend>
<?php } ?>
<table id="table" width="100%" border="1">
<?php if($nome_grupo != $dados['grupo']){ ?>
<tr>
<td><center><b>Item1</b></center></td>
<td><center><b>Item2</b></center></td>
<td><center><b>Item3</b></center></td>
<td><center><b>Item4</b></center></td>
<td><center><b>Item5</b></center></td>
<td><center><b>Item6</b></center></td>
</tr>
<?php } ?>
<tr bgcolor="#EFEFEF" onMouseOver="this.style.backgroundColor='#D1D7DC'" onMouseOut="this.style.backgroundColor='#EFEFEF'">
<td><?php echo $dados['Item1']; ?></td>
<td><?php echo $dados['Item2r']; ?></td>
<td><?php echo $dados['Item3']; ?></td>
<td><?php echo $dados['Item4']; ?></td>
<td>R$ <?php echo $dados['Item5'];?></td>
<td><?php echo $dados['Item6']; ?></td>
</tr>
<?php if($nome_grupo != $dados['grupo']){ ?>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>Tota de cada grupo:</td>
</tr>
<?php } ?>
</table>
<?php $nome_grupo = $dados['grupo']; }} ?>
</fieldset>
Vejam o código, alguma diga será bem vinda, obg.
Discussão (7)
Carregando comentários...