dc_jt Posted May 14, 2007 Share Posted May 14, 2007 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 More sharing options...
jitesh Posted May 14, 2007 Share Posted May 14, 2007 for ($i=(date('Y')-1);$i<=date('Y')+2;$i++){ Link to comment https://forums.phpfreaks.com/topic/51300-starting-a-year-loop-with-last-year/#findComment-252638 Share on other sites More sharing options...
dc_jt Posted May 14, 2007 Author Share Posted May 14, 2007 I tried that before posting but now the default date is todays date but 2006? Link to comment https://forums.phpfreaks.com/topic/51300-starting-a-year-loop-with-last-year/#findComment-252642 Share on other sites More sharing options...
dc_jt Posted May 14, 2007 Author Share Posted May 14, 2007 Its ok Ive sorted it, thanks anyway Link to comment https://forums.phpfreaks.com/topic/51300-starting-a-year-loop-with-last-year/#findComment-252645 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.