title: Mysqli insert fails when using for loop
body: <p>I'm trying to make a program that keep track of some cargo containers and what is in them.</p>
  
  <p>The form is divided in 2 parts. The first part ask about the shipment like if it is truck or container and expected arrival date. This info is stored in a DB lets call it shippinginfo. Upon adding it to the DB it get a unigue id (int auto inc). I also retrieve the ID to use to link the cargo to the shipping info.</p>
  
  <p>The second part of the form is the cargo.. like article-lotno-qty
  instead of writing 20 rows i do a for loop
  The idea is to write the ID retrieved from the first part of the form (shipping info) and then the cargo info in another DB lets call it cargoDB</p>
  
  <p>Here in my insert statement i use a for loop to loop trough the inserts to add them to the database but this is where it all goes to #¤%".</p>
  
  <p>It adds the shipping info fine, i retrieve the id fine and it adds the first line of the cargo to the cargo DB but no matter what I do it will not add the other cargo lines to the DB.</p>
  
  <p>I tried to print it to screen just to see the loop works and it prints just fine.</p>
  
  <p>the code for the add to DB is</p>
  
  <pre><code>if($insert_stmt = $mysqli-&gt;prepare("INSERT INTO RegisterFPCargo (sID, artNo, lotNo, productionDate, bestbeforeDate, qty) VALUES (?, ?, ?, ?, ?, ?)")) {
      for($i = 1; $i &lt;= $NumberofRows ; $i++){ 
          if($_POST['artNo'.$i] &lt;&gt; "") { 
              $insert_stmt-&gt;bind_param('issssi', $tID, $_POST['artNo'.$i], $_POST['lotNo'.$i], $_POST['pDate'.$i], $_POST['bbDate'.$i], $_POST['qty'.$i]);
              echo $_POST['artNo'.$i]."&lt;br&gt;"; //Debug
              $insert_stmt-&gt;execute();
          }
      }
  }
  echo $tID;
  </code></pre>
  
  <p>Please help me.</p>