I have a database that contains the name of some buttons and icons for two languages. the table is called icons and it has 4 fields (id, abbr, lang1, lang2) where abbr is the name of the variable I want to create and if the language is set to lang1 to assign the cell lang1 to the variable.
Example of the table:
id abbr lang1 lang2
-----------------------------------------------
1 air AirConditioner Condizionatore
2 pool Pool Piscina
I know that I can do that with something like that
foreach (array('wifi','fridge','air','balcony','kitchen','tv','bathroom','pool') as $varname) {
if ($$varname==1)
{
SQL Select to get the information for each field
}
But I was thinking that it will be nicer if I can do that dynamically, in case I add additional rows in the table
The desired result will be to have something like this created automatically for each row
if ($lang==lang1)
{
$air=$row['lang1'];
$pool=$row['lang1'];
}
else
{
$air=$row['lang2'];
$pool=$row['lang2'];
}
I have searched if someone faced this before, but couldn't find anything usefull for my case, so any help will be welcome.
Thanks