I have a PHP while loop that loads user comments – I need to exclude the most recent row in the database.
$sql = "SELECT c.trackid, c.comment, c.time, c.userid, u.id, u.username FROM
comments c
LEFT JOIN users u
ON u.id = c.userid
WHERE trackid='$trackid'
ORDER BY c.time DESC";
$i=1;
while ($row = mysql_fetch_assoc($result)) {
echo "<div class=\"commentDivs\">" . $row['time'] ."<br><br> " . $row['username'] . "<div class=\"userPostedComments\">" . $row['comment'] . "</div></div>";
}
How do I exclude the most recent row from the loop?
you can do it this way you will have to run 2 queries first to find the id of the latest comment ….
This will give you the latest id and then you can run the next query like this
and let us know what you trying to do , might be that will make your code more clean