Jump to content

Date loop function


dc_jt

Recommended Posts

Hi Im using the following date loop function and was just wondering if my function is correct?

 

Where I have for ($i=2007;$i<=date('Y')+4;$i++)

 

At the moment my drop down displays 2007 until 2011. Therefore, in 2008 will it display 2008 upto 2012 and so on.

 

 

			<tr>
			<td width="28%">Date</td>
<td><select name="sdated"> 
<? 
for ($i=1;$i<=31;$i++)
{?><?
echo "<option value=\"$i\"";
if ($_GET['iNewsId'] && $oNewsArticle->formatted_date != '00/00/0000')
{
	if ($i == $aDay) echo " selected";
	echo ">$i</option>";
} else {
	if ($i == $day) echo " selected";
	echo ">$i</option>";
}
}
?> 
</select>

<select name="sdatem"> 
<? 
for ($i=1;$i<=12;$i++)
{?><?
echo "<option value=\"$i\"";
if ($_GET['iNewsId'] && $oNewsArticle->formatted_date != '00/00/0000')
{
	if ($i == $aMonth) echo " selected";
	echo ">$i</option>";
} else {
	if ($i == $month) echo " selected";
	echo ">$i</option>";
}
}
?> 
</select> 
  
<select name="sdatey"> 
<?php
for ($i=2007;$i<=date('Y')+4;$i++)
    {?>
  <?php echo "<option value=\"$i\"";
  if ($_GET['iNewsId'] && $oNewsArticle->formatted_date != '00/00/0000')
  {
  	if ($i == $aYear) echo " selected";
  	echo ">$i</option>";
  } else {
  	if ($i == $year) echo " selected";
  	echo ">$i</option>";
  }
    }
?>

Link to comment
https://forums.phpfreaks.com/topic/48954-date-loop-function/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.