I am programming a webpage which uses a select option
dropdown menu to change the language in a MySQL table. There are currently only two language options. I simply want the menu to reflect the current value from the MySQL table.
I retreive the value from MySQL and assign it to variable $valuelanguage
. Here is the php code which I am using, that is not working:
<select id="language" name="language">
<?php
if($valuelanguage=="en")
{
echo '<option selected value="en">English</option>';
echo '<option value="de">Deutsch</option>';
}
else
{
echo '<option value="en">English</option>';
echo '<option selected value="de">Deutsch</option>';
}
?>
</select>
At the moment, if my $valuelanguage
is de then the menu should change to "Deutsch" as the selected option, but instead it stays at "English". Where am I going wrong?