for loop help
3 posts
• Page 1 of 1
for loop help
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: Select all
for($yearnum = date("Y", time()); $yearnum < $yearnum+2; $yearnum++)
{
echo " <option>$yearnum</option>";
}
i just really dont understand this
If I understand correctly what you need, you could try something like :
- Code: Select all
$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
3 posts
• Page 1 of 1
Return to HTML, CSS, and Scripts
Who is online
Users browsing this forum: No registered users and 7 guests