Re: Print current and next three years
| From: | Marek Kilimajer | Date: | Wed, 24 Sep 2003 12:41:44 +0000 |
| Subject: | Re: Print current and next three years | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-163720@lists.php.net to get a copy of this message | ||
$current=date('Y');
for($i=0;$i<4;$i++){
echo $current + $i;
}
Shaun wrote:
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