PHP Variable in SQL Select


#1

Using a variable in the select sql statement below. Have echoed out the variable and is presenting the correct value. when used in the datalist SQL select, not having any luck? any ideas?

<datalist id="ampgain1">
<?php
$ampgainsql = "SELECT ('".$amp1."') FROM ampgain";
$resultgain = (mysqli_query($link, $ampgainsql));
    while($gains = mysqli_fetch_assoc($resultgain))
    {
      "<option value='" . $gains['".$amp1."']."'>" . $gains['".$amp1."'] . "</option>";
}
$gain1 = $_GET['ampgain1'];
    ?>
</datalist>

#2

You shouldn’t be trying to dynamically select a column. This indicates a bad database design. What does your table look like and what result do you want the query to produce?