seguinte, to com um pequeno problema num script em php...eu adiciono os dados de um cadastro para o cliente e queria que a lista de resultados fosse ordenada pela data de nascimento. So que coloquei a data de nascimento do tipo varchar, pra poder pegar o dia, mes e ano...
o meu problema eh que o script dos resultados soh faz a ordem pelo dia, ou seja se uma pessoa faz aniversario dia 01/10 outra 03/12 e outra 05/03, ele coloca assim:
01/10
03/12
05/03
quando deveria no meu caso ser assim:
05/03
01/10
03/12
abaixo segue o script, se alguem tiver uma ideia do que eu possa fazer para conseguir fazer a ordem...
resultados.php
<?php //faz a conexao ao banco $conexao = mysql_connect("mysql.site.com.br", "login", "senha") or die ("Erro na conexão ao banco de dados."); $db = mysql_select_db("banco_dados") or die ("Erro ao selecionar a base de dados."); //monta e executa consulta em SQL $sql = "SELECT * FROM cadastro ORDER BY nascimento DESC LIMIT 100"; $resultado = mysql_query($sql) or die ("Não foi possível realizar a consulta."); ?> <html> <body style="background:#000000; color:#FFFFFF; font-family:Verdana, Arial, Helvetica, sans-serif;"> <div align="center"> <table border="1" bordercolor="#3C0101" style="border-collapse: collapse; margin-top: 20px;" align="center"> <tr> <th width="20px" bgcolor="#3C0101" style="font-size: 12px; color: #FFFFFF;">data nascimento</th> <th width="200px" bgcolor="#3C0101" style="font-size: 12px; color: #FFFFFF;">nome</th> <th width="10px" bgcolor="#3C0101" style="font-size: 12px; color: #FFFFFF;">ddd</th> <th width="20px" bgcolor="#3C0101" style="font-size: 12px; color: #FFFFFF;">telefone</th> <th width="200px" bgcolor="#3C0101" style="font-size: 12px; color: #FFFFFF;">e-mail</th> <th width="100px" bgcolor="#3C0101" style="font-size: 12px; color: #FFFFFF;">endereco</th> <th width="20px" bgcolor="#3C0101" style="font-size: 12px; color: #FFFFFF;">cidade</th> <th width="20px" bgcolor="#3C0101" style="font-size: 12px; color: #FFFFFF;">cep</th> <th width="10px" bgcolor="#3C0101" style="font-size: 12px; color: #FFFFFF;">estado</th> <th width="20px" bgcolor="#3C0101" style="font-size: 12px; color: #FFFFFF;">sexo</th> <th width="20px" bgcolor="#3C0101" style="font-size: 12px; color: #FFFFFF;">id</th> <th width="80px" bgcolor="#3C0101" style="font-size: 12px; color: #FFFFFF;">deletar</th> </tr> <?php //mostra os dados na tela while ($linha=mysql_fetch_array($resultado)) { echo "<tr>"; echo "<td style='font-size: 10px; text-align: center;'>{$linha['nascimento']}</td>"; echo "<td style='font-size: 10px; text-align: center;'>{$linha['nome']}</td>"; echo "<td style='font-size: 10px; text-align: center;'>{$linha['ddd']}</td>"; echo "<td style='font-size: 10px; text-align: center;'>{$linha['telefone']}</td>"; echo "<td style='font-size: 10px; text-align: center;'>{$linha['email']}</td>"; echo "<td style='font-size: 10px; text-align: center;'>{$linha['endereco']}</td>"; echo "<td style='font-size: 10px; text-align: center;'>{$linha['cidade']}</td>"; echo "<td style='font-size: 10px; text-align: center;'>{$linha['cep']}</td>"; echo "<td style='font-size: 10px; text-align: center;'>{$linha['estado']}</td>"; echo "<td style='font-size: 10px; text-align: center;'>{$linha['sexo']}</td>"; echo "<td style='font-size: 10px; text-align: center;'>{$linha['id']}</td>"; echo "<td style='font-size: 10px; text-align: center;'><a style='text-decoration: none;' href='excluir_cadastro.php?id={$linha['id']}'><img src='icon_deletar_news.jpg' border='0' /></a></td>"; echo "</tr>"; } echo "</table>"; echo "<div style=\"position: relative; margin-top: 10px; width: 80px; height: 20px; background-color: #3C0101;\"><a style=\"text-decoration: none;\" href=\"index.php\"><div style=\"color: #FFFFFF; font-size: 10px; font-weight: bold; padding: 4px; border: 0; font-family:Verdana, Arial, Helvetica, sans-serif;\">home</div></a></div>"; // echo "O arquivo <b>".$arquivo."</b> foi gerado com SUCESSO !"; echo "</div>"; echo "</body>"; echo "</html>"; ?>
qiualquer tipo de ajuda eh valido, acho que eu conseguindo faze o script ignorar as aspas eu consigo colocar em ordem de nascimento correta, mas nao tenho ideia de como fazer isso, por isso peço ajuda!!!
abrass