[SOLVED] ORDER by date DESC limit 10
Posted: Fri Jan 23, 2004 9:21 pm
here's my code
i am aware of the fact that the above code only returns the topic with the newest date 10 times, but what i cant figure out is what i have to do to get the top 10 newest posts and not just the newest one 10 times....
any input would be awesome....
Code: Select all
$topic_num = "1";
Print <<< EOT
<a href=index.php?l=add_topic.html>Add a Topic</a>
<br><br>
<table bordercolor='#000000' width=100% border=1 cellspacing=1>
<tr>
<td height=35 width=300>subject</td>
<td height=35 width=200>author</td>
<td height=35 width=20>replies</td>
<td height=35 width=20>views</td>
<td height=35 width=60>date</td>
<tr>
EOT;
while($topic_num<"10")
{
$query = mysql_query("SELECT * FROM topics ORDER by date DESC limit 10");
$array = mysql_fetch_array($query);
Print <<< EOT
<tr>
<td height=35>{$array['subject']}</td>
<td height=35>{$array['author']}</td>
<td height=35>{$array['replies']}</td>
<td height=35>{$array['views']}</td>
<td height=35>{$array['date']}</td>
<tr>
EOT;
$topic_num++;
}
Print <<< EOT
</table><br>
<a href=index.php?l=add_topic.html>Add a Topic</a>
EOT;any input would be awesome....