Estou fazendo um relatorio com os seguintes campos:
Curso - O nome curso
Pré-inscritos - Quantos alunos estão pré-inscritos no curso
Inscritos - Quantos alunos estão inscritos no curso
Total - Total de inscritos e total de pré-inscritos
O relatorio deverá aparecer da seguinte forma:
Nome do Curso Pré-inscritos Inscritos Total
CONTABILIDADE PARA INICIANTES 2 1 3
REDAÇÃO OFICIAL E A NOVA ORTOGRAFIA 1 1 2
Da forma que estou fazendo está saindo assim:
Nome do Curso Pré-inscritos Inscritos Total
CONTABILIDADE PARA INICIANTES 2 1 3
REDAÇÃO OFICIAL E A NOVA ORTOGRAFIA 2 1 3
Ou seja está repetindo
Abaixo segue o código:
<div align="justify"><font size="3" color="#000000"> </font> <?php require_once("../connections/conexao.php"); $consulta = mysql_query("SELECT * FROM inscricoes GROUP BY id_curso"); //$consulta = mysql_query("SELECT * FROM inscricoes"); while($resultado = mysql_fetch_array($consulta)) { $id_curso = $resultado["id_curso"]; // Aqui pego o id curso $aluno = $resultado["id_aluno"]; // Aqui eu pego o id do aluno $status = $resultado["status"]; // Aqui eu pego o id do aluno ?> <table align='center' width='1024' border='0' cellspacing='1' cellpadding='0' bgcolor='#FFFFFF'> <tr> <td align='left' class='imprimir2' bgcolor='#FFFFFF'></td> </tr> <tr> <td align='left' class='imprimir2' bgcolor='#FFFFFF' width='50%'> <?php $sql = "SELECT * FROM cursos WHERE id = '$id_curso' GROUP BY id"; $resultado = mysql_query($sql) or die ("Problema na Consulta"); While ($linha = mysql_fetch_array($resultado)) $nome_curso = $linha['nome']; { ?> <table width="1165" border="0"> <tr> <td colspan="9"></td> </tr> <tr> <td width="160"><strong><font color="#000000" size="2" face="Arial, Helvetica, sans-serif">Curso</font></strong></td> <td width="130"><strong><font color="#000000" size="2" face="Arial, Helvetica, sans-serif">Pré-Inscritos</font></strong></td> <td width="180"><strong><font color="#000000" size="2" face="Arial, Helvetica, sans-serif">Inscritos</font></strong></td> <td width="80"><strong><font color="#000000" size="2" face="Arial, Helvetica, sans-serif">Total</font></strong></td> </tr> <tr> <?php $somar = mysql_query("SELECT COUNT(id) as Total FROM inscricoes where status='inscrito'"); $totalid = mysql_fetch_array($somar); $somar2 = mysql_query("SELECT COUNT(id) as Total FROM inscricoes where status='preinscrito'"); $totalid2 = mysql_fetch_array($somar2); $total_geral = $totalid['Total'] + $totalid2['Total']; ?> <td> <font size="2" face="Arial, Helvetica, sans-serif"> <?= $nome_curso;?> <?= $statusr;?> </font></td> <td><font size="2" face="Arial, Helvetica, sans-serif"> ( <? echo $totalid2['Total']; ?> ) </font></td> <td><font size="2" face="Arial, Helvetica, sans-serif"> ( <? echo $totalid['Total']; ?> ) </font></td> <td><font size="2" face="Arial, Helvetica, sans-serif"> ( <? echo $total_geral; ?> ) </font></td> </tr> </table> <?php } ?> </td> </tr> <tr> </tr> </table> <table width="1024" border="0"> </table> <?php } ?> <div align="center" style="margin-top:20px"> </div> </div>
Quem Puder me ajudar agradeceria muito