Jump to content

Starting a year loop with last year


dc_jt

Recommended Posts

Hi I have the following which loops through the present year and adds two more years on:

 

However, I want it to be exactly the same but to start from last year rather than this year. Is this possible?

 

Thanks

 

 <select name="sdatey" class="fmgreynormal"> 
<?php
for ($i=date('Y');$i<=date('Y')+2;$i++)
    {?>
  <?php echo "<option value=\"$i\"";
  if ($_GET['iNewsId'] && formatDate($oObj->article_date) != '00/00/0000')
  {
  	if ($i == $aYear) echo " selected";
  	echo ">$i</option>";
  } else {
  	if ($i == $year) echo " selected";
  	echo ">$i</option>";
  }
    }
?>
</select>

Link to comment
https://forums.phpfreaks.com/topic/51300-starting-a-year-loop-with-last-year/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.