Hi,
I am using this drop down list.Loop started from 1920 to 2012.I am trying to put 1st value --select-- not 1920.
Need suggestion

<select name="year" id="year" style="height: 22px">
    <?php
         for($y=1920; $y<=2012; $y++)
        {
	?>
<option value="<?php echo $y; ?>" <?php if($y==$_POST["year"]) echo "selected"; ?> > <?php echo $y; ?> </option>
    <?php
	}
    ?>
    </select>
<select name="year" id="year" style="height: 22px">
    <option value="">--Select--</option>
    <?php
    for($y=1920; $y<=2012; $y++)
    {
    ?>
    <option value="<?php echo $y; ?>" <?php if($y==$_POST["year"]) echo "selected"; ?> > <?php echo $y; ?> </option>
    <?php
    }
    ?>
    </select>

@jacob-use the solution provided by karthik.....

I suggest to use standard mode, i.e., 'selected' should be 'selected="selected". But, what for '--Select--' when there is already the default selected item, 2012 for now.

Be a part of the DaniWeb community

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