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> Quote 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++){ Quote 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? Quote 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 Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.