title: Next Months PHP Calendar
body: <p>I have a web page where I am putting 4 simple calendars which show the dates for the next 4 months. I have got the code for showing the current month but I'm unsure of how to edit the code to show the second, third and fourth months. Here is the code that I am using to find the current month:</p>
  
  <pre><code>&lt;table&gt;
  &lt;?php
  $today = date("d"); // Current day
  $month = date("m"); // Current month
  $year = date("Y"); // Current year
  $days = cal_days_in_month(CAL_GREGORIAN,$month,$year); // Days in current month
  
  $lastmonth = date("t", mktime(0,0,0,$month-1,1,$year)); // Days in previous month
  
  $start = date("N", mktime(0,0,0,$month,1,$year)); // Starting day of current month
  $finish = date("N", mktime(0,0,0,$month,$days,$year)); // Finishing day of  current month
  $laststart = $start - 1; // Days of previous month in calander
  
  $counter = 1;
  $nextMonthCounter = 1;
  
  if($start &gt; 5){ $rows = 6; }else {$rows = 5; }
  for($i = 1; $i &lt;= $rows; $i++){
      echo '&lt;tr class="week"&gt;';
      for($x = 1; $x &lt;= 7; $x++){             
  
          if(($counter - $start) &lt; 0){
              $date = (($lastmonth - $laststart) + $counter);
              $class = 'class="blur"';
          }else if(($counter - $start) &gt;= $days){
              $date = ($nextMonthCounter);
              $nextMonthCounter++;
  
              $class = 'class="blur"';
  
          }else {
              $date = ($counter - $start + 1);
              if($today == $counter - $start + 1){
                  $class = 'class="today"';
              }
          }
  
  
          echo '&lt;td '.$class.'&gt;&lt;a class="date"&gt;'. $date . '&lt;/a&gt;&lt;/td&gt;';
  
          $counter++;
          $class = '';
      }
      echo '&lt;/tr&gt;';
  }
  ?&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>What variables do I need to change to make this work for future months?</p>