hi,
i am really struggling to find a way around this one but i am sure it's something simple for those who know.
i am working on a page where my user will input two languanges from a form: a mother language and a target language. these are stored under $mothlang and $targlang. i have a db table with words stored in many languages, with field names english, spanish, german etc. etc.
to get an english word from a row i would just use this code:
echo $row['english'];
to get the spanish:
echo $row['spanlish']; etc.
but what i want is to use the variable to control what is retrieved from the table. so something like this code:
echo $row['$mothlang'];
this code doesn't work however. obviously there is a correct way to do this but i can't find the answer anywhere. any help greatly appreciated.
variable inside a $row statement
Moderator: General Moderators
Re: variable inside a $row statement
Code: Select all
echo $row[$mothlang];Code: Select all
$s = "String";
echo 'This is a $s';
echo "This is a $s";
echo "This is a ".$s;
echo 'This is a '.$s;There are 10 types of people in this world, those who understand binary and those who don't
Re: variable inside a $row statement
I knew it would be something simple. Many thanks for you your time. That has solved the problem and I have learned something. 