EKKi: Formular mit Select

Beitrag lesen

Mahlzeit Bobby,

noch kürzer:

foreach ($array as $bla) {

echo "<option value='$bla'".(($_POST["irgendwas"]==$bla)?" selected='selected'":"").">$bla</option>";
}

  
Noch übersichtlicher (und richtiger):  
  
~~~php
foreach ($array as $bla) {  
  printf('<option value="%s"%s>%s</option>', htmlspecialchars($bla), (($_POST['irgendwas'] == $bla) ? ' selected="selected"' : ''), htmlspecialchars($bla));  
}

MfG,
EKKi

--
sh:( fo:| ch:? rl:( br:> n4:~ ie:% mo:} va:) de:] zu:) fl:{ ss:) ls:& js:|