title: How to get field name of table using object in php without running a separate query to get column names?
body: <p>Hi I am exporting data in excel format and for that I need to first get the field(column) names of table. For that I am using object to do this but I don't know the function name or property to get the field name. Below is a small section of the code I am using to do so it only gets the field names.</p>
  
  <pre><code>$SQL = "SELECT  * from assignments";
  $header = '';
  $result ='';
  $exportData = $conn-&gt;query ($SQL ) or die ( "Sql error : " .     $conn-&gt;error( ) );
  
  $fields = $exportData-&gt;field_count;
  
  for ( $i = 0; $i &lt; $fields; $i++ )
  {
      //Get field name using object instead of using mysql_field_name($exportData,$i) because exportData is an object and it wont work.
  } 
  </code></pre>
  
  <p>Edit:I don't want to run separate query to get column names because I am already getting records from that table so I would prefer to use a function or property to get its field names.  </p>