SELECT * FROM download WHERE DownloadType = ? AND Live = 1 ORDER BY YEAR(DownloadDate) DESC, DownloadDate ASC
And I think I see the error in my logic... try this:
<?php if ($Downloads->TotalRows > 0) { // Show if mysqli recordset not empty ?>
<?php
$showYear = "";
?>
<?php
$wa_startindex = 0;
while(!$Downloads->atEnd()) {
$wa_startindex = $Downloads->Index;
?>
<?php
if ($showYear != date("Y", strtotime($Downloads->getColumnVal("DownloadDate")))) {
?>
<?php
if ($showYear != "") echo("</div></div>");
?><div class="container downloadWrapper">
<h3 class="heading-1"><?php echo(date("Y", strtotime($Downloads->getColumnVal("DownloadDate")))); ?></h3>
<div class="container downloadContainer">
<?php
}
?>
<a class="link-text downloadLnk" href="downloads/<?php echo($Downloads->getColumnVal("DownloadFile")); ?>" target="_blank"><?php echo($Downloads->getColumnVal("DownloadTitle")); ?></a>
<?php
if ($showYear != date("Y", strtotime($Downloads->getColumnVal("DownloadDate")))) {
$showYear = date("Y", strtotime($Downloads->getColumnVal("DownloadDate")));
?>
<?php
}
?>
<?php
$Downloads->moveNext();
}
$Downloads->moveFirst(); //return RS to first record
unset($wa_startindex);
unset($wa_repeatcount);
?></div>
</div>
<?php } // Show if mysqli recordset not empty ?>