I'm trying to make a program that keep track of some cargo containers and what is in them.
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.
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
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 #¤%".
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.
I tried to print it to screen just to see the loop works and it prints just fine.
the code for the add to DB is
if($insert_stmt = $mysqli->prepare("INSERT INTO RegisterFPCargo (sID, artNo, lotNo, productionDate, bestbeforeDate, qty) VALUES (?, ?, ?, ?, ?, ?)")) {
for($i = 1; $i <= $NumberofRows ; $i++){
if($_POST['artNo'.$i] <> "") {
$insert_stmt->bind_param('issssi', $tID, $_POST['artNo'.$i], $_POST['lotNo'.$i], $_POST['pDate'.$i], $_POST['bbDate'.$i], $_POST['qty'.$i]);
echo $_POST['artNo'.$i]."<br>"; //Debug
$insert_stmt->execute();
}
}
}
echo $tID;
Please help me.
"; //Debug` that isn't the way to "debug". Get the real error(s) http://php.net/manual/en/mysqli.error.php --- http://php.net/manual/en/function.error-reporting.php – Funk Forty Niner Sep 25 '16 at 20:00