<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Comments on snippet: 'Year List Select Box'</title>
<link>http://snipplr.com</link>
<description>Snipplr comments feed'</description>
<language>en-us</language>
<pubDate>Wed, 19 Jun 2013 10:41:00 GMT</pubDate>
<item>
<title>iridium said on 11/2/10</title>
<link>http://snipplr.com/view/14466/year-list-select-box/</link>
<description><![CDATA[ $ageLimit is designed to set the default year that shows up in the select box to a certain number of years ago. So if for example I'm using this for a signup form on a site aimed at over 13 year olds, I can set $ageLimit to 13, and it will automatically work out what the birth year would be for a 13 year old and set it as the default. It was a function required for the original use of this code.

If you want to get rid of it, remove lines 4, 5, 6 &amp; 10, and on line 14 change $selectYear to $thisYear. ]]></description>
<pubDate>Tue, 02 Nov 2010 22:27:51 GMT</pubDate>
<guid>http://snipplr.com/view/14466/year-list-select-box/</guid>
</item>
<item>
<title>superman said on 10/24/10</title>
<link>http://snipplr.com/view/14466/year-list-select-box/</link>
<description><![CDATA[ I'm just not getting the point of $ageLimit in the code. What if I don't need it what should be that point which I replace within my code. I just need to use it for years no one is entering age there. Please suggest. 

Regards ]]></description>
<pubDate>Sun, 24 Oct 2010 12:54:20 GMT</pubDate>
<guid>http://snipplr.com/view/14466/year-list-select-box/</guid>
</item>
<item>
<title>iridium said on 10/19/10</title>
<link>http://snipplr.com/view/14466/year-list-select-box/</link>
<description><![CDATA[ Not sure what is wrong with the original code, other than the missing select tags? It was created to make only the options list itself, not the entire select box (mentioned in the blurb). ]]></description>
<pubDate>Tue, 19 Oct 2010 21:07:00 GMT</pubDate>
<guid>http://snipplr.com/view/14466/year-list-select-box/</guid>
</item>
<item>
<title>nikoda said on 9/22/10</title>
<link>http://snipplr.com/view/14466/year-list-select-box/</link>
<description><![CDATA[ Oh dear that code was messed up.

with age limit and year starting where the age limit kicks in the code should be:

$thisYear = date('Y');

$selectYear = ($thisYear - $yearRange);

$startYear = ($thisYear - $ageLimit);

echo "select";

foreach (range($selectYear, $startYear) as $year) {

	$selected = "";

		if($year == $startYear) { 

		$selected = " selected"; 

		}

		echo '' . $year . '/option';

	} ]]></description>
<pubDate>Wed, 22 Sep 2010 08:20:39 GMT</pubDate>
<guid>http://snipplr.com/view/14466/year-list-select-box/</guid>
</item>
<item>
<title>nikoda said on 9/22/10</title>
<link>http://snipplr.com/view/14466/year-list-select-box/</link>
<description><![CDATA[ Sorry for my lack of being able to put the code in properly.

Long live people who share their code... ]]></description>
<pubDate>Wed, 22 Sep 2010 08:12:03 GMT</pubDate>
<guid>http://snipplr.com/view/14466/year-list-select-box/</guid>
</item>
<item>
<title>nikoda said on 9/22/10</title>
<link>http://snipplr.com/view/14466/year-list-select-box/</link>
<description><![CDATA[ Damn... I can't post the code properly

ok.. without the < and > then...

// Number of years to go back 

$yearRange = 100;

// Selected Age

$ageLimit = 18;

// Generate Options

$thisYear = date('Y');

$startYear = ($thisYear - $yearRange);

$selectYear = ($thisYear - $ageLimit);

echo "select";

foreach (range($thisYear, $startYear) as $year) {

	$selected = "";

		if($year == $selectYear) { 

		$selected = " selected"; 

		}

		echo 'option' . $selected . '' . $year . '/option';

	}

echo "/select"; ]]></description>
<pubDate>Wed, 22 Sep 2010 08:10:43 GMT</pubDate>
<guid>http://snipplr.com/view/14466/year-list-select-box/</guid>
</item>
<item>
<title>nikoda said on 9/22/10</title>
<link>http://snipplr.com/view/14466/year-list-select-box/</link>
<description><![CDATA[ Sorry dude... your code is wrong.

The correct code is this.

// Number of years to go back
$yearRange = 100;

// Selected Age
$ageLimit = 18;

// Generate Options
$thisYear = date('Y');
$startYear = ($thisYear - $yearRange);
$selectYear = ($thisYear - $ageLimit);
echo "";
foreach (range($thisYear, $startYear) as $year) {
	$selected = "";
		if($year == $selectYear) { 
		$selected = " selected"; 
		}
		echo '' . $year . '';
	}
echo "";


within php tags.

Thanks for this script!

Irish James in Sweden ]]></description>
<pubDate>Wed, 22 Sep 2010 08:06:43 GMT</pubDate>
<guid>http://snipplr.com/view/14466/year-list-select-box/</guid>
</item>
</channel>
</rss>