带有Grid子条目的HTML / PHP / MYSQL表单

I am trying to add a "Line Item" Grid to and html form that will update a DB table

Filling out the child data could be done using a pop up form or updating the grid in line... The hard part I think will be saving the form in a way where the data is linked together in the DB... the sudo code would look a little like the below I imagine the grid would have a + button to add multiple line items. The line items would be saved to one table with an association to the summary, I think to achieve that I could just parse the post data into separate mysql insert statements so I am not sure there has to be a ton of separation?

<form class="form-horizontal">
    <fieldset>

    <!-- Form Name -->
    <legend>Form Name</legend>

    <!-- Text input-->
    <div class="form-group">
      <label class="col-md-4 control-label" for="textinput">Text Input</label>  
      <div class="col-md-4">
      <input id="textinput" name="textinput" type="text" placeholder="placeholder" class="form-control input-md">
      <span class="help-block">help</span>  
      </div>
    </div>

    <!-- Text input-->
    <div class="form-group">
      <label class="col-md-4 control-label" for="textinput">Text Input</label>  
      <div class="col-md-4">
      <input id="textinput" name="textinput" type="text" placeholder="placeholder" class="form-control input-md">
      <span class="help-block">help</span>  
      </div>
    </div>

    <!-- Textarea -->
    <div class="form-group">
      <label class="col-md-4 control-label" for="textarea">Text Area</label>
      <div class="col-md-4">                     
        <textarea class="form-control" id="textarea" name="textarea">default text</textarea>
      </div>
<!-- Start Grid Here -->

<!-- End Grid Here -->


    </div>

    </fieldset>
    </form>