title: Create input fields dynamically with values and column names from database
body: <p>I create inputs using the information in the columns for example if a field is called <code>about_content</code> it outputs a label of About Content with an input field. This works fine for inserting however I want to use this code similarly to <code>UPDATE</code> and I want to display to users the current value of a field as entered in the database. For example if <code>about_content = Hello World!</code> I want the input value to reflect that. Is there a way of doing this dynamically?</p>
  
  <pre><code>&lt;?php
  
  require('dbc.php');
  
  mysql_select_db($db);
  $resultInput = mysql_query("SHOW COLUMNS FROM about WHERE Field NOT IN 
  ('id', 'created', 'date_modified', 'last_modified', 'update', 'type', 'bodytext') 
  AND Field NOT REGEXP '_image'"); // selects only the columns I want
  
  $result = mysql_query("SELECT * FROM about WHERE id=".$_GET['id']); // values I want to put into the values for &lt;input&gt;
  
  while ($row = mysql_fetch_assoc ($result) &amp;&amp; $column = mysql_num_rows ($resultInput)) {
  
      foreach($row as $column =&gt; $value){
          echo '&lt;label&gt;'.$column.'&lt;input name="'.$column.'" type="input" value="'.$value.'"&gt;&lt;/label&gt;&lt;br&gt;';
      }
  }
  ?&gt;
  </code></pre>