Interrupting a while loop

I have a while loop that lists all events in my MYSQL database by date. All working fine.

However, I would like to break the list by month so that a header is shown only once then list the events in that month, inserts a header at the first record of the next month an so on. My current code is inserting the header after each event. I understand why, but cannot seem to come up with a way of doing this.

Code as follows:


while ($rows2 = mysql_fetch_assoc($result2)){
    
$next_title = $rows2['title'];
$long_string2 = $rows2['body'];
$next_link = $rows2['ID'];

$limit = 100;
if (strlen($long_string2) > $limit){
    $next_body = substr($long_string2, 0, strrpos(substr($long_string2, 0, $limit), ' ')) . '...';
    }else{
    $next_body = $long_string2;
    }

echo '<h2>'.$rows2['month_event'].'</h2>';


echo '<div id="calendar"><div id="date"><p class="date">'.$rows2['event_date'].'</p></div>
<div id="calendar_text">
<h3>'.$next_title.'</h3>
  <p class="news">'.nl2br($next_body).'</p>
  </div>
  <div id="date_link"><a href="events.php?id='.$rows2['ID'].'">read more>></a></div>  
  </div>';  

}

The header that defines the month is

echo ‘<h2>’.$rows2[‘month_event’].’</h2>’;

Any help or pointers in the right direction greatly appreciated.

Thanks