I have created a dropdown menu and wish to use the variable so acquired to select a column in MySQL query. I have used the following code:
<select name="selectedvalue">
    <option value="n1">Birthweight</option>
    <option value="n2">3-month weight</option>
    <option value="n3">6-month weight</option>
</select>
Later I am retrieving the variable using
$selval = ($_POST['selectedvalue']);
MySQL query:
$lambings = "Select year, `".($_POST['selectedvalue'])."` as weight from mytable 
      GROUP by year(dob)";
but the sql query fails every time.
 
     
    