<h3>2008</h3>
<?php
$query = "SELECT id, title, date_format(date,'%M %d, %Y') as date, date_format(date, '%Y') as year FROM pr WHERE del='N' and post='Y' ORDER BY id DESC";
$result = prod_query($query);
while ($row = mysql_fetch_array($result)){
if ($row['year'] == '2008') { echo "<p><strong><a href=\"/news/press_releases/full.php?id=$row[id]\">$row[date]</a></strong>: $row[title]</p>"; }
else { echo ''; }
} ?>
this is how i will do it if i were you, it might not the most efficient way, i believe you can enhance it from the sql query.
this is what i would do, it's just a pseudocode, not real php.. : ) but i believe it will make sense..
$query="select distinct(year) from pr group by year order by year" // select all the year
while ($row=mysql_fetch_array(mysql_query($query)) {
$query2 = "SELECT id, title, date_format(date,'%M %d, %Y') as date, date_format(date, '%Y') as year FROM pr WHERE del='N' and post='Y' and year=".$row['year']." ORDER BY id DESC";
$result = prod_query($query2);
while ($rowdata = mysql_fetch_array($result)){
echo "<p><strong><a href=\"/news/press_releases/full.php?id=$row[id]\">$row[date]</a></strong>: $row[title]</p>";
}
}
i dont think the code is error free, but basically the idea it there, first loop, find all the years, and second loop find all the data to the corresponding year. As a result, you don't have to use if else statment to group all the data in a spicific year.
hope this'd help..