carlg Posted October 5, 2008 Share Posted October 5, 2008 I have the following code: $query = "SELECT * FROM table"; $result = mysql_query($query); while ($row = mysql_fetch_assoc($result)){ print $row['$variable']; } What is the proper syntax to use on this line? print $row['$variable']; This code is part of a function and the column that I want to print is variable based upon which parameter is passed in. Thanks Link to comment https://forums.phpfreaks.com/topic/127114-solved-referring-to-mysql-columns-using-variables/ Share on other sites More sharing options...
carlg Posted October 5, 2008 Author Share Posted October 5, 2008 Figured it out myself. Solution is to get rid of the quotes. Thanks Link to comment https://forums.phpfreaks.com/topic/127114-solved-referring-to-mysql-columns-using-variables/#findComment-657529 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.