I'm creating standard php loop using the while function to display latest articles on my site and I want to display each date only once at the top of the article. Something like this: 19 February Article title 1 Article title 2 Article title 3 18 February Article title 4 Article title 5 Article title 6 Article title 7 17 February Article title 8 Article title 9 and so on... All the articles that is published on 18 February should be displayed under 18 February. How can I do that using php? Can anyone please help? Thanks in advance.
$last = ''; // This goes outside of your while loop while($row = mysql_fetch_assoc($result)) { // If date isn't the same as the last one parsed if($row['date'] != $last) { // Assign it to the holding var $last = $row['date']; // And echo it out echo $last; } } PHP: