0

Using the following variables

I have the Following table named everyones_friends; id, john, jack, bill, dave 1, jack, john, dave, bill 2, bill, dave, john, jack 3 dave, bill, jack, john

doing the following query;

$sql = "SELECT * FROM everyones_friends";
$mydata = mysql_query($sql);
while($record = mysql_fetch_array($mydata));
$display_column['$variable'];

My question is how do I display the "bill" column using a previously user selected variable since I know the $display_column['$variable']; won't work. Based on their choice one of the columns above goes into a dropdown.

1
  • Possible duplicate of stackoverflow.com/questions/20019484/mysql-how-to-use-a-variable-as-column-name Commented Jan 6, 2016 at 19:28

1 Answer 1

1

update this line to be :

$display_column[$variable];

single quota in php doesn't parse php variables.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.