I want make list years in PHP.List contains years of 1900 to 1992. Second problem is send my list to another
adress in GET metods.

Recommended Answers

All 6 Replies

Member Avatar
$list = implode(",",range(1900,1992));
echo "<a href='http://www.example.com?list=$list'>Send List</a>";

Perhaps you'd find a form easier?
Maybe also to urlencode the list before inserting

Thanks.But I need drop-down list.In HTML this is <select><option>.It
isn't recommended for a long list.

Best regards

Member Avatar

You did not ask for that originally.


Next time, state your questions as clearly as possible. We can simply write codes like this.


$min_year = 1900;
$max_year = 1992;

echo '<form>';
echo '<select name="year">';
foreach (range($max_year, $min_year, -1) as $x) {

    echo '<option value="'.$x.'">'.$x.'</option>';

echo '</select>';
echo '</br>';    
echo '<input type="submit" value="submit"/>';    
echo '</form>';  

-1 reverses the count from max_year to min_year. If you want 1900 to be the first on the option, then you can switch the position of the max_year and the min_year and then declare the step parameter to 1 , instead of -1.

Thanks very much.I will make precision question.

You could also consider using a datepicker [That is if you want to select a date of course].

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.