PHP+MySQL - consulta em ordem decrescente
Olá amigos tudo de bom!
tenho um mural de mensagem, tudo funcional enviar e visualizar as msg.
o que eu quero e não sei fazer é coloca a consulta(visualiza) em ordem decrescente
da ultima a primeira mensagem(maior ao menor).
PESSOAL O QUE EU QUERO É QUE CADA NOVA MENSAGEM ENVIADA FIQUE NO TOPO, SENDO A PRIMEIRA MENSAGEM.
eis o código de conexao e consulta:
<?php require_once('ligacao.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_ligacao, $ligacao);
$query_recado = "SELECT * FROM diadospais ORDER BY id DESC";
$recado = mysql_query($query_recado, $ligacao) or die(mysql_error());
$row_recado = mysql_fetch_assoc($recado);
$totalRows_recado = mysql_num_rows($recado);
?>
Código dos campos:
<?php do { ?>
<table width="600" border="0" align="center">
<tr>
<td width="263"><div align="left"><font color="#FFFF00" size="3px"><b><?php echo $row_recado['Nome']; ?></b></font></div></td>
<td width="327"><div align="right"><font color="#CCCCCC" size="3px"><?php echo $row_recado['Data']; ?></font></div></td>
</tr>
<tr>
<td><div align="left"><font color="#FFFFFF" size="3px"><?php echo $row_recado['Telefone']; ?></font></div></td>
<td><div align="right"><font color="#FFFFFF" size="3px"><?php echo $row_recado['Email']; ?></font></div></td>
</tr>
<tr>
<td colspan="2"><div align="justify"><font color="#FFFFFF" size="3px"><?php echo $row_recado['Mensagem']; ?></font></div></td>
</tr>
</table>
<?php } while ($row_recado = mysql_fetch_assoc($recado)); ?>
PESSOAL O QUE EU QUERO É QUE CADA NOVA MENSAGEM ENVIADA FIQUE NO TOPO, SENDO A PRIMEIRA MENSAGEM.
Agradeço ajuda!
Discussão (4)
Carregando comentários...