title: How to make an SQL query using variable column names?
body: <p>I am making a query like this:</p>
  
  <pre><code>$b1 = $_REQUEST['code'].'A'; //letter 'A' is concatenated to $_REQUEST['code']
  $a = $_REQUEST['num'];
  echo $b1.$a;
  $sql = "SELECT '".$b1."' FROM student_record1 WHERE id=".$a;
  $result = mysql_query($sql);
  if(!$result)
  {
      echo '&lt;p id="signup"&gt;Something went wrong.&lt;/p&gt;';
  }
  else
  {
      $str = $row[0]
      echo $str;
  }
  </code></pre>
  
  <p>Here <code>$b1</code> and <code>$a</code> are getting values from another page. The 'echo' in the third line is giving a correct result. And I am not getting any error in SQL. Instead, I am not getting any result from the SQL query. I mean echo at the last line.</p>