Forum Moderators: coopster
i have the following selection form in my php page:
<select name="lang">
<option value="german">german</option>
<option value="french">French</option>
<option value="english">English</option>
</select>
basically what i need to do is make one of those values selected depending on what url they are in. for example if the visitor is in mydomain.com/german/ then then above select form should be like this:
<select name="lang">
<option value="german" selected>german</option>
<option value="french">French</option>
<option value="english">English</option>
</select>
and if the user is in mydomain.com/english htne english should be selected, i need it to also work if the user is in lets say mydomain.com/english/contact/form.html
Any suggestions on how this can be achieved would be appreciated.
Cheers
Linda
<select name="lang">
<option value="english">English</option>
</select>
english should be selected if the folder name is "en" so myhost.com/en it should also work if its im currently in myhost.com/en/whatever
thanx
linda
[keep the $countries and $domainstrings in the same order]
How do people get -> to -> your country specific subdirectory? Maybe they can be given a session variable there to store where they are?
How do you alias your script so it responds from the various directories? (Unfamiliar with IIS...) Maybe there's something you can do in there? If it was apache one could use mod_rewrite to change /en/script.php to /script.php?country=en .... is there something similar to mod_rewrite in IIS?
<?php
$countries=array("german","french","english");
$domainstrings=array("de","fr","en");
echo "<select name=\"lang\">";
for($a=0;$a<sizeof($countries);$a++)
{
echo "<option value=\"$countries[$a]";
if (strpos($_REQUEST['lang'],$domainstrings[$a])) echo " SELECTED";
echo "\">".ucfirst($countries[$a])."</option>";
}
echo "</select>";
?>
<?php
$lang = "en";
$countries=array("german","french","english");
$domainstrings=array("de","fr","en");
echo "<select name=\"lang\">";
for($a=0;$a<sizeof($countries);$a++)
{
echo "<option value=\"$countries[$a]";
if (strpos($lang,$domainstrings[$a])) echo " SELECTED";
echo "\">".ucfirst($countries[$a])."</option>";
}
echo "</select>";
?>
what could be wrong?
<?php
$countries=array("german","french","english");
$domainstrings=array("de","fr","en");
echo "<select name=\"lang\">";
for($a=0;$a<sizeof($countries);$a++)
{
echo "<option value=\"$countries[$a]";
if ($_REQUEST['lang']==$domainstrings[$a]) echo " SELECTED";
echo "\">".ucfirst($countries[$a])."</option>";
}
echo "</select>";
?>
?
<?php
$countries=array("german","french","english");
$domainstrings=array("de","fr","en");
echo "<select name=\"lang\">";
for($a=0;$a<sizeof($countries);$a++)
{
echo "<option value=\"$countries[$a]";
if ($_REQUEST['lang']==$domainstrings[$a]) echo " SELECTED";
echo "\">".ucfirst($countries[$a])."</option>";
}
echo "</select>";
?>
then i called the test.php?lang=en but still no luck
<?php
$countries=array("german","french","english");
$domainstrings=array("de","fr","en");
echo "<select name=\"lang\">";
for($a=0;$a<sizeof($countries);$a++)
{
echo "<option value=\"$countries[$a]\"";
if ($_REQUEST['lang']==$domainstrings[$a]) echo " SELECTED";
echo ">".ucfirst($countries[$a])."</option>";
}
echo "</select>";
?>
sorry, my mistake, got a \" wrong