This question already has an answer here:
trying to make a compliments area of my test site
$result = mysql_query("SELECT message, username FROM compliments order by date DESC");
while($r = mysql_fetch_array($result))
{
$Name = $r["username"];
$Message = $r["message"];
}
this however, gets all the messages,
i want to limit to only the most recent 10
so i tried this..
$result = mysql_query("SELECT TOP(10) message, username FROM compliments order by date ASC");
while($r = mysql_fetch_array($result))
{
$Name = $r["username"];
$Message = $r["message"];
}
throws an error
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /var/www/vhosts/localhost/httpdocs/readcompliments.php on line 52
how can i do this successfuly?
EDIT:
Now using
SELECT message, username FROM compliments order by date ASC LIMIT 10
and it works! but the problem is, that its getting the oldest 10! how do i make it so it gets the most recent 10?
</div>