简体   繁体   中英

PHP MYSQL Display table column based on variable

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.

update this line to be :

$display_column[$variable];

single quota in php doesn't parse php variables.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM