title: PHP split the content of text area and insert into mysql
body: <p>I need to know how to do the following using php coding please</p>
  
  <ol>
  <li>take inserted text from a textarea</li>
  <li>split the content per line </li>
  <li>Insert each line into the database as its own row with own id number</li>
  </ol>
  
  <p>Can anyone show me how to do this please?</p>
  
  <p>thanks</p>
  
  <p>EDIT_<strong><em>_</em>__<em>_</em>__<em>_</em></strong></p>
  
  <p>THis is what I have tried so Far</p>
  
  <pre><code>$is_first = true;
  
  
  foreach (explode('\n', $_POST['code']) as &amp;$voucher) {
  
      if ($is_first) $is_first = false; else $query .= ', ';
  
      $query .= '(' . mysql_real_escape($voucher) . ')';
      mysql_query('INSERT INTO back_codes (`code_id`, `code`) VALUES (NULL, "$voucher")');
  }
  </code></pre>