Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Ederjsantos

[Resolvido] Juntar dados em uma tabela

Recommended Posts

Bom dia galera,

seguinte preciso montar uma tabela que tem dados de 2009 e 2010, entretando existem

dados de 2009 que são iguais os de 2010 e existem dados em 2010 que são diferentes de 2009,

os dados estão retornando certinho, porém os dados de 2009 so fica na parte de cima da minha tabela e

de 2010 aparece abaixo de 2009 e preciso que os dados fiquem um do lado do outro:

Esse é o código:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-ransitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>

<title>BH Séries Finais</title>
<table width='100%' style='border: 1px #c0c0c0 solid;' padding='2px'>

<tr>
<td rowspan="3" style="TEXT-ALIGN: center;background:#D8DFFF;">           Série/Ano            </td>
<td colspan="3" style="TEXT-ALIGN: center;background:#D8DFFF;"><p>2009</p></td>
<td colspan="3" style="TEXT-ALIGN: center;background:#D8DFFF;"><p>2010</p></td>
<td colspan="5" style="TEXT-ALIGN: center;background:#D8DFFF;">Alunos que não renovaram</td>
<td rowspan="2" colspan="2" style="TEXT-ALIGN: center;background:#D8DFFF;">Vagas Disponíveis</td>
</tr>

<tr>
<th colspan="3" style="TEXT-ALIGN: center;background:#D8DFFF;">Dados</th>
<th colspan="3" style="TEXT-ALIGN: center;background:#D8DFFF;">Dados</th>
<th colspan="5" style="TEXT-ALIGN: center;background:#D8DFFF;">Pendências (Rentecao de Requerimento)</th>
</tr>

<tr>
<th style="background:#D8DFFF;">Turno</th>
<th style="background:#D8DFFF;">Turmas</th>
<th style="background:#D8DFFF;">Alunos</th>
<th style="background:#D8DFFF;">Turno</th>
<th style="background:#D8DFFF;">Turmas</th>
<th style="background:#D8DFFF;">Alunos</th>
<th style="background:#D8DFFF;">Débito</th>
<th style="background:#D8DFFF;">SOE</th>
<th style="background:#D8DFFF;">Histórico</th>
<th style="background:#D8DFFF;">Biblioteca</th>
<th style="background:#D8DFFF;">Material</th>
<th style="background:#D8DFFF;">Capacidade</th>
<th style="background:#D8DFFF;">Vagas</th>
</tr>

 <?
 $notas_sql = "SELECT unidade, ano, grau, serie, turno, COUNT(qtd) AS Turmas,sum(capacidade) as Capacidade,sum(alunos)as 'QTD_ALUNOS',sum(retsoe) as Retsoe,sum(retdebito) as Debito,
 sum(rethistorico) as Historico,sum(retmaterial) as material,sum (retbiblioteca) as Biblioteca,
 sum(capacidade) as Capacidade

 FROM capacidade where unidade='3'
 GROUP BY unidade, ano, grau, serie, turno
 ORDER BY unidade, ano, grau, serie, turno";

 $notas_res = mssql_query($notas_sql);
 while($notas_reg = mssql_fetch_array($notas_res)){
 extract($notas_reg);
?>
<td style='text-align: center; background:#dbdbe5;'><?=$notas_reg['grau']?> - <?=$notas_reg['serie']?></td>

 <?php if($notas_reg['ano'] == 2009){
  $tex = "$turno";
  }else{
  $tex = "";
  }?>
 <td style='text-align: center; background:#dbdbe5;'> <?=$tex?></td>

 <?php if($notas_reg['ano'] == 2009){
  $turma = "$Turmas";
  }else{
  $turma = "";
  }?>
 <td style='text-align: center; background:#dbdbe5;'> <?=$turma?></td>

 <?php if($notas_reg['ano'] == 2009){
  $aluno = "$QTD_ALUNOS";
  }else{
  $aluno = "";
  }?>
 <td style='text-align: center; background:#dbdbe5;'> <?=$aluno?></td>

 <?php if($notas_reg['ano'] == 2010){
  $texto = "$turno";
  }else{
  $texto = "";
  }?>
<td style='text-align: center; background:#dbdbe5;'> <?=$texto?></td>

 <?php if($notas_reg['ano'] == 2010){
  $turm = "$Turmas";
  }else{
  $turm = "";
  } ?>
 <td style='text-align: center; background:#dbdbe5;'> <?=$turm?></td>

 <?php if($notas_reg['ano'] == 2010){
  $alun = "$QTD_ALUNOS";
  }else{
  $alun = " ";
  } ?>
 <td style='text-align: center; background:#dbdbe5;'> <?=$alun?></td>

 <?php if($notas_reg['ano'] == 2009){
  $debito = "$Debito";
  }else{
  $debito = " ";
  }?>
 <td style='text-align: center; background:#dbdbe5;'> <?=$debito?></td>

 <?php if($notas_reg['ano'] == 2009){
  $soe = "$Retsoe";
  }else{
  $soe = " ";
  }?>
 <td style='text-align: center; background:#dbdbe5;'> <?=$soe?></td>
<?php if($notas_reg['ano'] == 2009){
  $hist = "$Historico";
  }else{
  $hist = " ";
  }?>
 <td style='text-align: center; background:#dbdbe5;'> <?=$hist?></td>

 <?php if($notas_reg['ano'] == 2009){
  $bibli = "$Biblioteca";
  }else{
  $bibli = " ";
  }?>
 <td style='text-align: center; background:#dbdbe5;'> <?=$bibli?></td>

 <?php if($notas_reg['ano'] == 2009){
  $mate = "$material";
  }else{
  $mate = " ";
  }?>
 <td style='text-align: center; background:#dbdbe5;'> <?=$mate?></td>

 <?php if($notas_reg['ano'] == 2010){
  $cap = "$Capacidade";
  }else{
  $cap = " ";
  }?>
 <td style='text-align: center; background:#dbdbe5;'> <?=$cap?></td>

 <?php if($notas_reg['ano'] == 2010){
  $cap = "$Capacidade" - "$QTD_ALUNOS";
  }else{
  $cap = " ";
  }?>
 <td style='text-align: center; background:#dbdbe5;'> <?=$cap?></td>
</tr>
 <?}?>
 </table>
 </td>
 </tr>
 </table>

como faço para que os dados apareça de forma correta na minha tabela e nao os dados de 2009 e abaixo os dados de 2010, quero que apareça mesclado os dois anos, com um order by.

 

Obrigado.

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.