Post new topic    Reply to topic
Login to print this topic
Author Message
xion`silo
PostPosted: Thu Jun 12, 2008 3:17 pm Reply with quote

PRO Level 2
 
 


Joined: 02 Jun 2008
Posts: 15
Location: Austin, TX
I dont understand forloops and this is my attempt. lol
does any one know how to do a loop so that it adds a option for every year that is greater than the current year but no more than 5 years ahead?

Code:

for($yearnum = date("Y", time()); $yearnum < $yearnum+2; $yearnum++)
{
   echo "  <option>$yearnum</option>";
}


i just really dont understand this
 
Back to top
NoReflex
PostPosted: Thu Jun 12, 2008 5:58 pm Reply with quote

PRO Level 12
 
 


Joined: 17 Nov 2004
Posts: 609
Location: Romania
If I understand correctly what you need, you could try something like :
Code:

$year = date("Y", time())
for ($i=1;i<6;i++)
{
   echo "<option>".$year+i."</option>";
}


If you want to include the current year you could try to run the loop from 0 to 5.
Hope this helps you!

Best wishes,
John
 
Back to top
xion`silo
PostPosted: Mon Jun 16, 2008 1:11 am Reply with quote

PRO Level 2
 
 


Joined: 02 Jun 2008
Posts: 15
Location: Austin, TX
thanks dude smile
 
Back to top
Back to top
Index >> Webmaster Domain & Code Room >> for loop help

Page 1 of 1

Post new topic   Reply to topic


Tired of the Ads? Registered users have 80% less adverts.