I have dropdown on Enquiry page, some text boxes etc with a capthca below and submit button

I used this code for my text boxes

<input name="fld_name" type="text" id="fld_name" size="40" value="<?php if($_POST['fld_name']) { echo $_POST['fld_name']; } ?>" />

it keeps the data in the textboxes when the user does something worng like type in wrong captcha code.

The drop down boxes however dont wokr with that code lol, my code looks like this

<select name = "fld_wherehear" id="fld_wherehear" >
					  <option value = "0" selected>Select...</option>
	<option value = "1">Internet</option>
	<option value = "2">Newsletter</option>
	<option value = "3">Friend</option>
	<option value = "4">Magazine</option>
	<option value = "5">Other</option>
</select>
<select name = "fld_wherehear" id="fld_wherehear" >
					  <option value = "0" >Select...</option>
	<option value = "1" <?php echo (($_POST["fld_wherehear"]==1)?"selected":"") ;?> >Internet</option>
	<option value = "2" <?php echo (($_POST["fld_wherehear"]==2)?"selected":"") ;?>>Newsletter</option>
	<option value = "3" <?php echo (($_POST["fld_wherehear"]==3)?"selected":"") ;?>>Friend</option>
	<option value = "4" <?php echo (($_POST["fld_wherehear"]==4)?"selected":"") ;?>>Magazine</option>
	<option value = "5" <?php echo (($_POST["fld_wherehear"]==5)?"selected":"") ;?>>Other</option>
</select>

Its using if statement

<select name = "fld_wherehear" id="fld_wherehear" >
    <option value = "0" >Select...</option>
    <option value = "1" <?php if($_POST["fld_wherehear"]=="1") echo "selected"; ?> >Internet</option>
    <option value = "2" <?php if($_POST["fld_wherehear"]=="2") echo "selected"; ?> >Newsletter</option>
    <option value = "3" <?php if($_POST["fld_wherehear"]=="3") echo "selected"; ?> >Friend</option>
    <option value = "4" <?php if($_POST["fld_wherehear"]=="4") echo "selected"; ?> >Magazine</option>
    <option value = "5" <?php if($_POST["fld_wherehear"]=="5") echo "selected"; ?> >Other</option>
    </select>

and i was trying this code ... lol

<select name = "fld_wherehear" id="fld_wherehear" value="<?php if($_POST['fld_name']) { echo $_POST['fld_name']; } ?>">
					  <option value = "0" selected>Select...</option>
					  <option value = "1">Internet</option>
					  <option value = "2">Newsletter</option>
					  <option value = "3">Friend</option>
					  <option value = "4">Magazine</option>
					  <option value = "5">Other</option>
				    </select>

feel real dumb now, but im learning allot ...

THANKS You guys rock !!

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.