Ifoundyoufondoo Posted May 6, 2009 Share Posted May 6, 2009 Hi, just a quick question, what i am trying to do is basically this: <td class="cell" align="center" height="19">'.$row["$_SESSION['name']"].'</td> I.e. Placing the session variable within the row variable to obtain the result, however i as yet cannot get it to work, i assume its some clever combination of quotes and single quotes to achieve the correct syntax but i have yet to find it. Help would be much appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/157122-variables-within-variables-quick-question/ Share on other sites More sharing options...
Ken2k7 Posted May 6, 2009 Share Posted May 6, 2009 Someone needs to learn how to manage a DB better. But anyways... <td class="cell" align="center" height="19">'.$row["{$_SESSION['name']}"].'</td> Quote Link to comment https://forums.phpfreaks.com/topic/157122-variables-within-variables-quick-question/#findComment-827816 Share on other sites More sharing options...
Ifoundyoufondoo Posted May 6, 2009 Author Share Posted May 6, 2009 Well im only just starting out so give me a break Thanks though, that worked spot on. Quote Link to comment https://forums.phpfreaks.com/topic/157122-variables-within-variables-quick-question/#findComment-827822 Share on other sites More sharing options...
Ken2k7 Posted May 6, 2009 Share Posted May 6, 2009 Well im only just starting out so give me a break *Ken2k7 is thinking.... Nah, just learn DB design. At least I'm telling you what you read up on. Quote Link to comment https://forums.phpfreaks.com/topic/157122-variables-within-variables-quick-question/#findComment-827829 Share on other sites More sharing options...
w3evolutions Posted May 6, 2009 Share Posted May 6, 2009 I thought you were talking about a variable variable. Ex: $bar = "Hello"; $foo = "bar"; echo($$foo); // will display Hello What you are dealing with is simple array keys, and yes that is one way to do it as Ken2k7 stated. if you are using echo() to list the entire td element you can also do it this way: echo('<td class="cell" align="center" height="19">'.$row[$_SESSION['name']].'</td>'); same difference. Quote Link to comment https://forums.phpfreaks.com/topic/157122-variables-within-variables-quick-question/#findComment-827834 Share on other sites More sharing options...
premiso Posted May 6, 2009 Share Posted May 6, 2009 if you are using echo() to list the entire td element you can also do it this way: echo('<td class="cell" align="center" height="19">'.$row[$_SESSION['name']].'</td>'); same difference. Not really. The method you posted, since concatenation is being used, will be faster/more efficient by microseconds. Quote Link to comment https://forums.phpfreaks.com/topic/157122-variables-within-variables-quick-question/#findComment-827840 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.