Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6153111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:02:19+00:00 2026-05-23T20:02:19+00:00

And, would a loop be more efficient then listing them out one by one?

  • 0

And, would a loop be more efficient then listing them out one by one?

<select name="birthdayYear" >
    <option value="0000"<?php echo $birthdayYear == '0000' ? 'selected="selected"' : ''; ?>>Year:</option>
    <option value="2011"<?php echo $birthdayYear == '2011' ? 'selected="selected"' : ''; ?>>2011</option>
    <option value="2010"<?php echo $birthdayYear == '2010' ? 'selected="selected"' : ''; ?>>2010</option>
    <option value="2009"<?php echo $birthdayYear == '2009' ? 'selected="selected"' : ''; ?>>2009</option>
    <option value="2008"<?php echo $birthdayYear == '2008' ? 'selected="selected"' : ''; ?>>2008</option>
    <option value="2007"<?php echo $birthdayYear == '2007' ? 'selected="selected"' : ''; ?>>2007</option>
    <option value="2006"<?php echo $birthdayYear == '2006' ? 'selected="selected"' : ''; ?>>2006</option>
    <option value="2005"<?php echo $birthdayYear == '2005' ? 'selected="selected"' : ''; ?>>2005</option>
    <option value="2004"<?php echo $birthdayYear == '2004' ? 'selected="selected"' : ''; ?>>2004</option>
    <option value="2003"<?php echo $birthdayYear == '2003' ? 'selected="selected"' : ''; ?>>2003</option>
    <option value="2002"<?php echo $birthdayYear == '2002' ? 'selected="selected"' : ''; ?>>2002</option>
    <option value="2001"<?php echo $birthdayYear == '2001' ? 'selected="selected"' : ''; ?>>2001</option>
    <option value="2000"<?php echo $birthdayYear == '2000' ? 'selected="selected"' : ''; ?>>2000</option>
    <option value="1999"<?php echo $birthdayYear == '1999' ? 'selected="selected"' : ''; ?>>1999</option>
    <option value="1998"<?php echo $birthdayYear == '1998' ? 'selected="selected"' : ''; ?>>1998</option>
    <option value="1997"<?php echo $birthdayYear == '1997' ? 'selected="selected"' : ''; ?>>1997</option>
    <option value="1996"<?php echo $birthdayYear == '1996' ? 'selected="selected"' : ''; ?>>1996</option>
    <option value="1995"<?php echo $birthdayYear == '1995' ? 'selected="selected"' : ''; ?>>1995</option>
    <option value="1994"<?php echo $birthdayYear == '1994' ? 'selected="selected"' : ''; ?>>1994</option>
    <option value="1993"<?php echo $birthdayYear == '1993' ? 'selected="selected"' : ''; ?>>1993</option>
    <option value="1992"<?php echo $birthdayYear == '1992' ? 'selected="selected"' : ''; ?>>1992</option>
    <option value="1991"<?php echo $birthdayYear == '1991' ? 'selected="selected"' : ''; ?>>1991</option>
    <option value="1990"<?php echo $birthdayYear == '1990' ? 'selected="selected"' : ''; ?>>1990</option>
    <option value="1989"<?php echo $birthdayYear == '1989' ? 'selected="selected"' : ''; ?>>1989</option>
    <option value="1988"<?php echo $birthdayYear == '1988' ? 'selected="selected"' : ''; ?>>1988</option>
    <option value="1987"<?php echo $birthdayYear == '1987' ? 'selected="selected"' : ''; ?>>1987</option>
    <option value="1986"<?php echo $birthdayYear == '1986' ? 'selected="selected"' : ''; ?>>1986</option>
    <option value="1985"<?php echo $birthdayYear == '1985' ? 'selected="selected"' : ''; ?>>1985</option>
    <option value="1984"<?php echo $birthdayYear == '1984' ? 'selected="selected"' : ''; ?>>1984</option>
    <option value="1983"<?php echo $birthdayYear == '1983' ? 'selected="selected"' : ''; ?>>1983</option>
    <option value="1982"<?php echo $birthdayYear == '1982' ? 'selected="selected"' : ''; ?>>1982</option>
    <option value="1981"<?php echo $birthdayYear == '1981' ? 'selected="selected"' : ''; ?>>1981</option>
    <option value="1980"<?php echo $birthdayYear == '1980' ? 'selected="selected"' : ''; ?>>1980</option>
    <option value="1979"<?php echo $birthdayYear == '1979' ? 'selected="selected"' : ''; ?>>1979</option>
    <option value="1978"<?php echo $birthdayYear == '1978' ? 'selected="selected"' : ''; ?>>1978</option>
    <option value="1977"<?php echo $birthdayYear == '1977' ? 'selected="selected"' : ''; ?>>1977</option>
    <option value="1976"<?php echo $birthdayYear == '1976' ? 'selected="selected"' : ''; ?>>1976</option>
    <option value="1975"<?php echo $birthdayYear == '1975' ? 'selected="selected"' : ''; ?>>1975</option>
    <option value="1974"<?php echo $birthdayYear == '1974' ? 'selected="selected"' : ''; ?>>1974</option>
    <option value="1973"<?php echo $birthdayYear == '1973' ? 'selected="selected"' : ''; ?>>1973</option>
    <option value="1972"<?php echo $birthdayYear == '1972' ? 'selected="selected"' : ''; ?>>1972</option>
    <option value="1971"<?php echo $birthdayYear == '1971' ? 'selected="selected"' : ''; ?>>1971</option>
    <option value="1970"<?php echo $birthdayYear == '1970' ? 'selected="selected"' : ''; ?>>1970</option>
    <option value="1969"<?php echo $birthdayYear == '1969' ? 'selected="selected"' : ''; ?>>1969</option>
    <option value="1968"<?php echo $birthdayYear == '1968' ? 'selected="selected"' : ''; ?>>1968</option>
    <option value="1967"<?php echo $birthdayYear == '1967' ? 'selected="selected"' : ''; ?>>1967</option>
    <option value="1966"<?php echo $birthdayYear == '1966' ? 'selected="selected"' : ''; ?>>1966</option>
    <option value="1965"<?php echo $birthdayYear == '1965' ? 'selected="selected"' : ''; ?>>1965</option>
    <option value="1964"<?php echo $birthdayYear == '1964' ? 'selected="selected"' : ''; ?>>1964</option>
    <option value="1963"<?php echo $birthdayYear == '1963' ? 'selected="selected"' : ''; ?>>1963</option>
    <option value="1962"<?php echo $birthdayYear == '1962' ? 'selected="selected"' : ''; ?>>1962</option>
    <option value="1961"<?php echo $birthdayYear == '1961' ? 'selected="selected"' : ''; ?>>1961</option>
    <option value="1960"<?php echo $birthdayYear == '1960' ? 'selected="selected"' : ''; ?>>1960</option>
    <option value="1959"<?php echo $birthdayYear == '1959' ? 'selected="selected"' : ''; ?>>1959</option>
    <option value="1958"<?php echo $birthdayYear == '1958' ? 'selected="selected"' : ''; ?>>1958</option>
    <option value="1957"<?php echo $birthdayYear == '1957' ? 'selected="selected"' : ''; ?>>1957</option>
    <option value="1956"<?php echo $birthdayYear == '1956' ? 'selected="selected"' : ''; ?>>1956</option>
    <option value="1955"<?php echo $birthdayYear == '1955' ? 'selected="selected"' : ''; ?>>1955</option>
    <option value="1954"<?php echo $birthdayYear == '1954' ? 'selected="selected"' : ''; ?>>1954</option>
    <option value="1953"<?php echo $birthdayYear == '1953' ? 'selected="selected"' : ''; ?>>1953</option>
    <option value="1952"<?php echo $birthdayYear == '1952' ? 'selected="selected"' : ''; ?>>1952</option>
    <option value="1951"<?php echo $birthdayYear == '1951' ? 'selected="selected"' : ''; ?>>1951</option>
    <option value="1950"<?php echo $birthdayYear == '1950' ? 'selected="selected"' : ''; ?>>1950</option>
    <option value="1949"<?php echo $birthdayYear == '1949' ? 'selected="selected"' : ''; ?>>1949</option>
    <option value="1948"<?php echo $birthdayYear == '1948' ? 'selected="selected"' : ''; ?>>1948</option>
    <option value="1947"<?php echo $birthdayYear == '1947' ? 'selected="selected"' : ''; ?>>1947</option>
    <option value="1946"<?php echo $birthdayYear == '1946' ? 'selected="selected"' : ''; ?>>1946</option>
    <option value="1945"<?php echo $birthdayYear == '1945' ? 'selected="selected"' : ''; ?>>1945</option>
    <option value="1944"<?php echo $birthdayYear == '1944' ? 'selected="selected"' : ''; ?>>1944</option>
    <option value="1943"<?php echo $birthdayYear == '1943' ? 'selected="selected"' : ''; ?>>1943</option>
    <option value="1942"<?php echo $birthdayYear == '1942' ? 'selected="selected"' : ''; ?>>1942</option>
    <option value="1941"<?php echo $birthdayYear == '1941' ? 'selected="selected"' : ''; ?>>1941</option>
    <option value="1940"<?php echo $birthdayYear == '1940' ? 'selected="selected"' : ''; ?>>1940</option>
    <option value="1939"<?php echo $birthdayYear == '1939' ? 'selected="selected"' : ''; ?>>1939</option>
    <option value="1938"<?php echo $birthdayYear == '1938' ? 'selected="selected"' : ''; ?>>1938</option>
    <option value="1937"<?php echo $birthdayYear == '1937' ? 'selected="selected"' : ''; ?>>1937</option>
    <option value="1936"<?php echo $birthdayYear == '1936' ? 'selected="selected"' : ''; ?>>1936</option>
    <option value="1935"<?php echo $birthdayYear == '1935' ? 'selected="selected"' : ''; ?>>1935</option>
    <option value="1934"<?php echo $birthdayYear == '1934' ? 'selected="selected"' : ''; ?>>1934</option>
    <option value="1933"<?php echo $birthdayYear == '1933' ? 'selected="selected"' : ''; ?>>1933</option>
    <option value="1932"<?php echo $birthdayYear == '1932' ? 'selected="selected"' : ''; ?>>1932</option>
    <option value="1931"<?php echo $birthdayYear == '1931' ? 'selected="selected"' : ''; ?>>1931</option>
    <option value="1930"<?php echo $birthdayYear == '1930' ? 'selected="selected"' : ''; ?>>1930</option>
    <option value="1929"<?php echo $birthdayYear == '1929' ? 'selected="selected"' : ''; ?>>1929</option>
    <option value="1928"<?php echo $birthdayYear == '1928' ? 'selected="selected"' : ''; ?>>1928</option>
    <option value="1927"<?php echo $birthdayYear == '1927' ? 'selected="selected"' : ''; ?>>1927</option>
    <option value="1926"<?php echo $birthdayYear == '1926' ? 'selected="selected"' : ''; ?>>1926</option>
    <option value="1925"<?php echo $birthdayYear == '1925' ? 'selected="selected"' : ''; ?>>1925</option>
    <option value="1924"<?php echo $birthdayYear == '1924' ? 'selected="selected"' : ''; ?>>1924</option>
    <option value="1923"<?php echo $birthdayYear == '1923' ? 'selected="selected"' : ''; ?>>1923</option>
    <option value="1922"<?php echo $birthdayYear == '1922' ? 'selected="selected"' : ''; ?>>1922</option>
    <option value="1921"<?php echo $birthdayYear == '1921' ? 'selected="selected"' : ''; ?>>1921</option>
    <option value="1920"<?php echo $birthdayYear == '1920' ? 'selected="selected"' : ''; ?>>1920</option>
    <option value="1919"<?php echo $birthdayYear == '1919' ? 'selected="selected"' : ''; ?>>1919</option>
    <option value="1918"<?php echo $birthdayYear == '1918' ? 'selected="selected"' : ''; ?>>1918</option>
    <option value="1917"<?php echo $birthdayYear == '1917' ? 'selected="selected"' : ''; ?>>1917</option>
    <option value="1916"<?php echo $birthdayYear == '1916' ? 'selected="selected"' : ''; ?>>1916</option>
    <option value="1915"<?php echo $birthdayYear == '1915' ? 'selected="selected"' : ''; ?>>1915</option>
    <option value="1914"<?php echo $birthdayYear == '1914' ? 'selected="selected"' : ''; ?>>1914</option>
    <option value="1913"<?php echo $birthdayYear == '1913' ? 'selected="selected"' : ''; ?>>1913</option>
    <option value="1912"<?php echo $birthdayYear == '1912' ? 'selected="selected"' : ''; ?>>1912</option>
    <option value="1911"<?php echo $birthdayYear == '1911' ? 'selected="selected"' : ''; ?>>1911</option>
    <option value="1910"<?php echo $birthdayYear == '1910' ? 'selected="selected"' : ''; ?>>1910</option>
    <option value="1909"<?php echo $birthdayYear == '1909' ? 'selected="selected"' : ''; ?>>1909</option>
    <option value="1908"<?php echo $birthdayYear == '1908' ? 'selected="selected"' : ''; ?>>1908</option>
    <option value="1907"<?php echo $birthdayYear == '1907' ? 'selected="selected"' : ''; ?>>1907</option>
    <option value="1906"<?php echo $birthdayYear == '1906' ? 'selected="selected"' : ''; ?>>1906</option>
    <option value="1905"<?php echo $birthdayYear == '1905' ? 'selected="selected"' : ''; ?>>1905</option>
    <option value="1904"<?php echo $birthdayYear == '1904' ? 'selected="selected"' : ''; ?>>1904</option>
    <option value="1903"<?php echo $birthdayYear == '1903' ? 'selected="selected"' : ''; ?>>1903</option>
    <option value="1902"<?php echo $birthdayYear == '1902' ? 'selected="selected"' : ''; ?>>1902</option>
    <option value="1901"<?php echo $birthdayYear == '1901' ? 'selected="selected"' : ''; ?>>1901</option>
    <option value="1900"<?php echo $birthdayYear == '1900' ? 'selected="selected"' : ''; ?>>1900</option>
</select>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T20:02:19+00:00Added an answer on May 23, 2026 at 8:02 pm
    <select name="birthdayYear" >
        <option value="0000"<?php echo $birthdayYear == '0000' ? 'selected="selected"' : ''; ?>>Year:</option>
    
    <?php
    for($i=date('Y'); $i>1899; $i--) {
        $selected = '';
        if ($birthdayYear == $i) $selected = ' selected="selected"';
        print('<option value="'.$i.'"'.$selected.'>'.$i.'</option>'."\n");
    }
    ?>
    
    </select>
    

    And, would a loop be more efficient then listing them out one by one?

    I don’t think you have to worry about efficiency. Using a loop just looks cleaner it will be easier to maintain I think.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When a select field is changed, I would like to loop through all of
I was wondering if it would be more efficient to use document.getElementById() n number
I need to write some code that would loop though all rows of a
I need a for loop which would print from year 2000 to 2099. [Bindable]
How to get a counter inside xsl:for-each loop that would reflect the number of
A friend was in need of an algorithm that would let him loop through
I am creating a dynamic cursor and I would like to loop over the
I would like to be able to loop through all of the defined parameters
I would like to know how to loop through each line in a text
I would like to call a Python script from within a Bash while loop.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.