title: How do I enter multiple line items into mysql database using php
body: <p>I'm trying to create an RMA form. The idea is to have the ability to enter multiple rows with on one page. The problem I'm having is that if I have the form with more than one row it only submits the top row of data. I looked around and read that I should be using a foreach() and implode() function but I can't seem to get it to work.</p>
  
  <p>This is my entire PHP code that  currently WORKS with a single row. If someone could please help me get multiple rows in as well that'd be great. Also I don't have much experience with php/mysql so if you could please list an example instead of saying "use x,y,z functions" because that hasn't helped me so far.</p>
  
  <p>All assisstance is greatly appreciated. Thanks</p>
  
  <pre><code>&lt;html&gt;&lt;head&gt;&lt;title&gt; TEST - RMA&lt;/title&gt;&lt;/head&gt;
  &lt;body&gt;
  &lt;h1&gt;RMA Screen&lt;/h1&gt;
  &lt;h2&gt;Order Results&lt;/h2&gt;
  &lt;?php
    $controller_serial = $_POST['controller'];
    $sample_holder_serial = $_POST['sampleholder'];
    $first_name = $_POST['firstname'];
    $last_name = $_POST['lastname'];
    $randomnumber = $_POST['RMAnum'];
  
  
    $link = mysql_connect('localhost', 'user', 'abcd'); 
    if (!$link) 
    {
      die('Could not connect: ' . mysql_error()); 
    }
    echo 'Connected successfully';
  
    mysql_select_db(rma);
  
    $randomnumber = mt_rand(1,100);
    while( $fetch = mysql_fetch_array( 
      mysql_query("SELECT `RMAnum` FROM `rma` 
                   WHERE `RMAnum` = $randomnumber") ) ) {
      $randomnumber = mt_rand(1,10);
  
    }
  
    mysql_query("INSERT INTO `rma` 
              (`controller_serial`, `sample_holder_serial`
              , `first_name`, `last_name`, `RMAnum`)
              VALUES('$controller_serial','$sample_holder_serial'
              , '$first_name', '$last_name', '$randomnumber')") 
      or die(mysql_error());
    mysql_close($link);
  
  
    echo 'Thanks for submitting the form.&lt;br /&gt;';
    echo 'RMA NUMBER: ' . $randomnumber . '&lt;br /&gt;';
    echo 'Controller Serial Number: ' . $controller_serial . '&lt;br /&gt;';
    echo 'Sample Holder Serial Number: ' . $sample_holder_serial . '&lt;br /&gt;';
    echo 'First Name: ' . $first_name . '&lt;br /&gt;';
    echo 'Last Name: ' . $last_name . '&lt;br /&gt;';
  ?&gt;
  
  &lt;/body&gt;&lt;/html&gt;
  </code></pre>