[PHP] Print current and next three years

[PHP] Print current and next three years

Post by subs » Thu, 25 Sep 2003 21:47:26


<select name="start_date_year">
<?
for( $i=0;$i<3;$i++ ) {
$year = date( 'Y' )+$i;
echo '<option value="'.$year.'">'.$year.'</option>';
}
?>
</select>

Edward Dudlik
Becoming Digital
www.becomingdigital.com



----- Original Message -----
From: "Shaun" < XXXX@XXXXX.COM >
To: < XXXX@XXXXX.COM >
Sent: Wednesday, 24 September, 2003 08:29
Subject: [PHP] Print current and next three years


Hi,

I am trying to print the current and next three years in a form. Using the
following code I can only print 2000, 2001, 2002, 2003:

<select name="start_date_year">
<?php
$i = 1;
while ($i <= 4){
if ($i + 1 == date("Y", strtotime($_GET[mysql_date]))){
echo '<option value="'.date("Y", mktime(0, 0, 0, 0, 0, $i)).'"
selected>'.date("Y", mktime(0, 0, 0, 0, 0, $i)).'</option>';
} else {
echo '<option value="'.date("Y", mktime(0, 0, 0, 0, 0,
$i)).'">'.date("Y", mktime(0, 0, 0, 0, 0, $i)).'</option>';
}
$i++;
}
?>
</select>

How can I get this code to start looping from the current year?

Thanks for your help

--
PHP General Mailing List ( http://www.yqcomputer.com/ )
To unsubscribe, visit: http://www.yqcomputer.com/