Código só funciona no linux
Tenho windows e linux no meu notebook rodando wamp e lamp respectivamente, porém o código abaixo só funciona no linux:
<!-- AGRUPADO POR MES/ANO -->
<table width="100%" class="tblGrid">
<th colspan="3">TOTAL POR MES/ANO</th>
<tr>
<td align="center"><b>MÊS/ANO</b></td>
<td align="center"><b>TOTAL</b></td>
<td align="center"><b>PERCENTUAL</b></td>
</tr>
<?php
$sql = "SELECT *, COUNT(*) AS total FROM viagens GROUP BY mes, YEAR(data) ORDER BY total DESC";
$query = mysql_query($sql);
while ($linha = mysql_fetch_array($query)) {
$data = explode("-",$linha['data']);
$ano = $data[0];
?>
<tr>
<td align="lefth"><?php echo strtoupper ($linha['mes'])."/".$ano; ?></td>
<td align="right"><?php echo $linha['total']; ?></td>
<td align="right"><?php echo round ((($linha['total'] / $total) * 100),2)." %";?></td>
</tr>
<?php
}
?>
<tr>
<td>TOTAL</td>
<td align="right"><?php echo $total; ?></td>
<td align="right"><?php echo round ((($total / $total) * 100),2)." %";?></td>
</tr>
</table>
<p />
<a href="javascript:abrir('gerar_grafico.php','1080','600','yes');">Gerar gráfico</a>
<br />
Esse código no windows retorna a seguinte mensagem:
Notice: Undefined variable: total in C:\wamp\www\includes\ait\pormesano.php on line 28
Como resolver? Parece que no windows não aceita o alias do COUNT(*).
Discussão (10)
Carregando comentários...