title: Using Foreach loop for inserting data into 70 fields long database
body: <p>I have 70 text fields in my HTML form. I want to insert data from those fields to the database using php and mysqli. So I thought of using the foreach loop while creating the sql query..I tried the following, but I am not able to get the required result.</p>
  
  <pre><code>foreach ($_POST as $key =&gt; $value) {
  $f = $f . "," . $key ;
  $v = $v . ",'" . $value . "'";      
  }
  $sql = "insert into table1($f) values ($v)";
  </code></pre>
  
  <p>The variable<code>f</code>is supposed to carry a string of comma seperated field names which are fields of the <code>$_POST</code> array. While variable <code>v</code> is to carry single quoted comma seperated values of the <code>$_POST</code> array. I am getting an extra comma in the starting of <code>f</code> and <code>v</code> right now. How to remove that.</p>
  
  <p>Please help!</p>