hallo, ich habe eine liste mit geburtsjahren
<select name="select">
<option<?PHP echo $jahrcheck ; ?> 1933</option>
<option<?PHP echo $jahrcheck ; ?> 1934</option>
<option<?PHP echo $jahrcheck ; ?> 1935</option>
<option<?PHP echo $jahrcheck ; ?> 1936</option>
<option<?PHP echo $jahrcheck ; ?> 1937</option>
<option<?PHP echo $jahrcheck ; ?> 1938</option>
<option<?PHP echo $jahrcheck ; ?> 1939</option>
<option<?PHP echo $jahrcheck ; ?> 1940</option>
........
<option<?PHP echo $jahrcheck ; ?> 1990</option>
<option<?PHP echo $jahrcheck ; ?> 1991</option>
<option<?PHP echo $jahrcheck ; ?> 1992</option>
</select>dann habe ich eine variable mit dem richtigen jahr
$jahr = 1991
und das wort selected$jahrcheck = "selected ";
ich will es lösen, das nun das richtige jahr im formular gleich selected ist.
der code dafür würde dann quasi so aussehen
<option <?PHP echo $jahrcheck1 ; ?> 1991</option>
es geht mit if
if ($HTTP_SESSION_VARS[jahr] == "1991"):
$jahrcheck1 = "selected";
endif;aber da müsst ich ewig viel code schreiben,außerdem müsste ich noch jahrcheck durchnummerieren, gibt es da nicht was besseres?
danke
ronny
wie kann ich nun eine schleife bauen, die prüft welches jahr die variable hat und dann eben genau im richtigen feld das selected reinsetzt?
Das ist meine Meinung dazu.
Grüße,
Wolfram