title: How to display dates with same month as a single link?
body: <p>I have an archive section for my blog. Every time there is a post, I want it to automatically display month name and year as a list, so later on I can click to view posts from that month and year.</p>
  
  <p>I only know how to display using mysql_fetch_assoc, but this is going to keep repeating every row over and over, so I tried GROUP BY, but it does not help either.</p>
  
  <pre><code>&lt;div class="sidebox widget"&gt;
      &lt;h4&gt;Por Datas&lt;/h4&gt;
  
  &lt;?php 
  
  $query = "SELECT * FROM posts GROUP BY post_date";
  $select_all_post_by_dates = mysqli_query($connection, $query);
  
  while($row = mysqli_fetch_assoc($select_all_post_by_dates)) {
  
  $post_id = $row['post_id'];
  $post_date = $row['post_date'];
  $post_date_month_year = date_create($post_date)
  ?&gt;
  
  &lt;ul class="circled"&gt;
  &lt;li&gt;
  &lt;a href="#"&gt;&lt;?php echo date_format($post_date_month_year, "F Y")  ?&gt;
  &lt;/a&gt;
  &lt;/li&gt;
  &lt;/ul&gt;&lt;!-- /.circled --&gt;
  
  &lt;?php } ?&gt;
  &lt;a href="#" class="txt-btn"&gt;All archives&lt;/a&gt;
  &lt;/div&gt;&lt;!-- /.widget --&gt;
  </code></pre>
  
  <p>The results are the months repeating one below the other, for example:</p>
  
  <p>April 2019
  April 2019
  April 2019</p>
  
  <p>In case I have one more post in May</p>
  
  <p>April 2019
  April 2019
  April 2019
  May 2019</p>
  
  <p>And I needed: </p>
  
  <p>April 2019
  May 2019</p>