Hi everyone. I have a fairly simple problem, but need some guidance.
I have a news section on my front page, and I want it to list the most recent articles. However, I only want it to print the date once per date - if there are more than one news items for, say, June 1 2005, I would only want it to print the date heading once, and then carry on again for any other dates.
Here is the code I'm working with:
$query = "SELECT title, LEFT(body, 200) AS b, category, DATE_FORMAT(add_date, '%M %e, %Y') AS d FROM news WHERE category='corpath' OR category='all' ORDER BY d DESC LIMIT 3";
if ($result == null) {
echo "There is currently no news.";
} else {
while ($row = mysql_fetch_array ($result)) {
echo "<h2 class=\"news\">" . $row['d'] . "</h2>";
echo "<dl class=\"news\"><dt><a href=\"asdf\">" . $row['title'] . "</a>" . "</dt><dd><p>" . $row['b'] . "...</p></dd></dl>";
}
}
Thanks a lot.