title: Insert statement with automatically generated columns
body: <p>I want to create an INSERT statement using the columns of my table and NULL or blank values for the content except for the id, created_by .etc. I am trying to avoid duplicates. Right now I get:</p>
  
  <pre><code>INSERT INTO testimonials (id, created, created_by, id, quote, name, position, company, published, created, created_by, last_modified_by, last_modified) VALUES ('257927816', NOW(), '1', '')
  </code></pre>
  
  <p>and I would like to have blank values iterate in the VALUES section for everything but the first 3, which I define.</p>
  
  <pre><code>function insertBlankWithID($table, $postFxn) {
      global $randomID;
      $id = $randomID;
      $resultInsert = mysql_query("SELECT * FROM " . $table);
      if (!$resultInsert) {
          echo '&lt;div class="ec-messages messages-error"&gt;'.QUERY_ERROR.'&lt;/div&gt;';
          include($cmsdir . FOOTER_EXIT);
          exit();
      }
      $columns = array();
      while ($row = mysql_fetch_assoc($resultInsert)) {
          if (empty($columns)) {
              $columns = array_keys($row);
          }
      }
      //$sql = 'INSERT INTO `testimonials` (`id`, `quote`, `name`, `position`, `company`, `published`, `created`, `created_by`, `last_modified_by`, `last_modified`) VALUES ('.$id.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);';
      $sql = sprintf("INSERT INTO %s (id, created, created_by, %s) VALUES ('".$id."', NOW(), '".$_SESSION['user_id']."', '%s')", $table, implode(', ', $columns), implode("',  '", ''));
      mysql_query($sql);
      /*
      if (!$sql) {
          echo '&lt;div class="ec-messages messages-error"&gt;'.QUERY_ERROR.'&lt;/div&gt;';
          exit();
      }
      */
      echo $sql;
  }
  // redirect(basename($_SERVER['PHP_SELF'], ".php").'?s=output&amp;id='.$id
  
  insertBlankWithID('testimonials', $postFxn);
  </code></pre>