title: MYSQL assign column name to variable?
body: <p>I have a database table which has two columns, <code>business</code> and <code>tourist</code>.</p>
  
  <p>I ask a user to select one of them from dropdown list, then use the result in a <code>SELECT</code> statement in MySQL. I assign this column to <code>$cclass</code>, then I make this statement <code>SELECT $cclass FROM flights ...</code>.</p>
  
  <p>But it always returns <code>NULL</code>. Why does it return <code>NULL</code> and how do I fix this?</p>
  
  <p>My code:</p>
  
  <pre><code>$check = mysql_query("SELECT $cclass FROM flights WHERE flight_no = '$flightno'");
  
  while ($result = mysql_fetch_assoc($check))
  {
      $db_seats = $result['$cclass']; 
  }
  </code></pre>