Forum Moderators: coopster
I don't know any other way to do this other than to have an individual variable like this:
<option name=name value=value $onevariableforeachoption>
where I would have a lot of if statements to see if the value is "name" and if it is then $onevariableforeachoption will be = to "selected"....
there has got to be a better way someone please let me know :)
thanks so much again everyone
$values=array('cat','dog','horse');
foreach ($values as $value) {
printf('<option name="name" value="%s" %s>',
$value,$value==$_POST['name']?'selected':'');
}
Untested code but it should work.
A less obscure way is:
foreach ($values as $value) {
if ($value==$_POST['name']) {
$selected='selected';
} else {
$selected='';
}
printf('<option name="name" value="%s" %s>',
$value,$selected);
}