using PHP how can you display the value selected in a drop down list?

  • Thread starter Thread starter djbennett999
  • Start date Start date
D

djbennett999

Guest
If you are using php to dynamically display an html form with error messages, how can you get it to have the option that user has chosen in the drop down list selected in the drop down list rather than it going back to the top item in the drop down list when the form is reloaded?
When the form is reloaded I still want the user to be able to select an option from the drop down list.
 
<option selected value="Something">Something</option>

you will have to define the value like

$state="La";

if($state == $state){
echo "<option selected=\"$state\" value=\"$state\">$state</option>";
}
else
{
echo "<option value=\"$state\">$state</option>";
}
}
 
Back
Top