I have a Joomla 3.1 site that is going to show reports about contributions made. The reports should be divided into groups by month and year. I have a code that pulls data from database but cannot make it put each month into a separate <div>
and each year into a parent <div>
to its months. How is it done? Here is my code.
<?php
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select(array($db->quoteName('contribution_date'), $db->quoteName('contribution_amount'), $db->quoteName('source')));
$query->from($db->quoteName('contribution'));
$db->setQuery($query);
$results = $db->loadObjectList();
?>
<table class='financial-reports'><th>aaa</th><th>bbb</th><th>ccc</th>
<?php
foreach ( $results as $result) {
echo '<tr>' . '<td class="fin-rep-date">' . JFactory::getDate($result->contribution_date)->format('d M, Y') . '</td>' .
'<td class="fin-rep-sum">' . $result->contribution_amount . ' ' .'руб.' . '</td>' .
'<td class="fin-rep-source">' . $result->source . '</td>' . '</tr>';
}
?>
</table>