Hi everyone,

Originally Posted by
JShor
Use the ORDER BY in your SQL selection query. For example:
Code:
SELECT * FROM `comments` WHERE id = 1 ORDER BY date DESC
You can change
DESC (descending order) to
ASC (ascending order).
A while back in the thread, comments box, I asked how to make the newest comment display at the top of all the other comments. The code worked except I've just realised that if you enter another comment on the same day, then it dosn't work. Any help would be great. Here's my current code
PHP Code:
<?php
// POST data wasnt entered, so display the comments and comment form
// view comments from database
$sql = mysql_query ("SELECT * FROM comments ORDER BY date DESC") or die(mysql_error());;
while ($row = mysql_fetch_array ($sql)) {
?>
<table border="0" cellspacing="0" cellpadding="4" width="500">
<tr>
<td>
<?php
echo $row['name'].'<br />';
?>
</td>
<td>
<?php
echo $row['date'].'<br />';
?>
</td> </tr>
</table><br />
<?php
echo $row['comments'].'<br />';
Bookmarks