title: Get column names from MySQL Table
body: <p>I have a Table in my MySQL Database which looks like this:</p>
  
  <pre><code>Table: VAAW
  Columns:
  ID  int(11) PK AI
  Voornaam    varchar(45) 
  Achternaam  varchar(45) 
  Adres   varchar(45) 
  Woonplaats  varchar(45) 
  </code></pre>
  
  <p>I am using this table in the following php code:</p>
  
  <pre><code>$strSQL     = "SELECT * FROM NAW.VAAW";
  $objQuery   = mysql_query($strSQL);
  while($objResult = mysql_fetch_array($objQuery))
  {
  $Voornaam   = $objResult["Voornaam"];
  $Achternaam = $objResult["Achternaam"];
  $Adres      = $objResult["Adres"];
  $Woonplaats = $objResult["Woonplaats"];
  
  $string     = $_POST['naam'];
  
  $vaaw       = array("(voornaam)", "(achternaam)", "(woonplaats)", "(adres)");
  $vervang    = array("$Voornaam", "$Achternaam", "$Woonplaats","$Adres");
  
  echo str_replace($vaaw, $vervang, $string);
  echo '&lt;br&gt;';
  }
  </code></pre>
  
  <p>What I use this for:<br>
  I have a form where I can add some tekst in a textbox and when I submit it will echo the result. For example if the Column 'Voornaam' contains the row 'Jack' and when I type in the textbox in my form: Hey (voornaam), it should output: Hey Jack.</p>
  
  <p>I don't really know how to ask this question so I will give an example. If I for some reason want to change a column name in my database I will have to change this source code according to the column name changes.</p>
  
  <p>The example:</p>
  
  <p>If I change the column name 'voornaam' to 'Vnaam' I will also have to change </p>
  
  <pre><code>$Voornaam  = $objResult["Voornaam"];
  </code></pre>
  
  <p>to </p>
  
  <pre><code>$Voornaam  = $objResult["Vnaam"];
  </code></pre>
  
  <p>So my question is if there is any way to have some sort of standard for like the 1st column, 2nd colum etc. so I can add that in the code and will not have to change the source code every time I change a column name. Maybe there is a query function to do this? I know this question is kinda vague but I hope you understand, if not feel free to ask in the comments. Any help would be great since I have no clue how to do this!</p>
  
  <p><em><strong>NOTE:</em></strong>
  I know I should't be using mysql_* and I will switch to PDO later. So please don't mention that again.</p>