TheFilmGod Posted December 18, 2007 Share Posted December 18, 2007 while ($i > 0 ){ $field = "a . $i"; ${$field} = $row_data['$field']; $i--; } This is what I'm trying to achieve. I found the problem to come from this: $test = a31; $hello = $row_data['$test'] Quote Link to comment Share on other sites More sharing options...
helraizer Posted December 18, 2007 Share Posted December 18, 2007 What problem would that be? What is actually going wrong with it, does it display any errors? Give us something to work with. Sam Quote Link to comment Share on other sites More sharing options...
TheFilmGod Posted December 18, 2007 Author Share Posted December 18, 2007 What problem would that be? What is actually going wrong with it, does it display any errors? Give us something to work with. Sam When I echo the variable, nothing is displayed. Quote Link to comment Share on other sites More sharing options...
kjtocool Posted December 18, 2007 Share Posted December 18, 2007 Can you post all the code and any output. Quote Link to comment Share on other sites More sharing options...
revraz Posted December 18, 2007 Share Posted December 18, 2007 I see 5 variables there. You really need to provide more info on what the problem is. What problem would that be? What is actually going wrong with it, does it display any errors? Give us something to work with. Sam When I echo the variable, nothing is displayed. Quote Link to comment Share on other sites More sharing options...
trq Posted December 18, 2007 Share Posted December 18, 2007 Ive no idea what your trying to do because you havent explained yourself at all. However, one problem with your code is that variables are not interpolated within single quotes. You might try.... <?php $i = 3; while ($i > 0 ) { $field = 'a' . $i; ${$field} = $row_data[$field]; // you do not need quotes around $field $i--; } echo $a3."\n"; echo $a2."\n"; echo $a1."\n"; ?> Does this help at all? Otherwise, we need more help from you explaining your issue. Quote Link to comment 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.