I have a table with a datetime column with multiple dates in. I want to output the month and year for every row that exists only once. e.g "
I've managed to get the below working, this displays "April May June", but it needs to display April twice as it is in different years and I also want to display their respective years.
<?php $results = mysqli_query($link, 'SELECT DISTINCT MONTH(date_added) AS "Month" FROM payments') or die("Query fail: " . mysqli_error($link)); ?> <?php foreach($results as $result) :?> <?php $monthText = date("F", strtotime("2001-" . $result['Month'] . "-01")); ?> <?= $monthText ?> <?php endforeach; ?>
I've been researching for hours and not manged to find a solution that works.