dukeispie dukeispie - 20 days ago 6
HTML Question

Forums Table Ranking Help (PHP / HTML)

I've recently created a forum with a table that displays data.

<div class="invis">
<div class="topic-top">
<table width="100%"><tr>
<td width="54%" style="color:white;">Topic</td>
</table>
</div>
<div class="topic-test">
<?php
while($thread=mysql_fetch_assoc($forum)){
echo "<tr>";
echo "<td><a href='threads?id=".$thread['id']."'
class='btn'>".$thread['title']."</a></td><hr>";
echo "</tr>";
}
?>
</tr>
</table>
</div>


When it displays data, it goes oldest first (by id). How do I make it display newest first?

Answer

Use MySQL to sort by ID in your query. You can read more about the order by clause here.

ORDER BY id DESC

Use ORDER BY id ASC to sort the opposite way.