I have a script that displays countries in different languages. For example "United Kingdom" in Spanish would be "Reino Unido", etc. Every language is stored in a different table, like "name_es" for Spanish or "name_en" for English. The correct table is then selected through a session value stored for each user. What I have is this:
if ($countries_id)
{
$sql_select_countries = $this->query_silent("SELECT name_".$_SESSION['language']." as name FROM " . DB_PREFIX . "countries WHERE
id IN (" . $countries_id . ")");
if ($sql_select_countries)
{
while ($country_details = $this->fetch_array($sql_select_countries))
{
$countries_array[] = $country_details['name'];
}
}
}
Note that the problem line is this:
$countries_array[] = $country_details['name'];
I need it to be something like
$countries_array[] = $country_details['name_$_SESSION['language']'];
But I can't figure out the correct syntax :(
query_silent()- I like the name!