$miid = $_POST['MI_Drg_Qty_ID']; //inward challan ids $mqty = $_POST['mqty']; //challan vice quanties in batch $hcode = $_POST['hcode']; //heat codes $bn->saveBatch(); $batchid = $bn->getBatchID(); $i = 0; $j = count($cdates); while ($i < $j) { $bn->setBatchID($batchid); $bn->setCommitedDate($cdates[$i]); $bn->setCommitedQty($cqty[$i]); $bn->setCommitedRemarks($cremark[$i]); $bn->saveCommitment(); $i++; } $i = 0; $j = count($miid); while ($i < $j) { $bn->setBatchID($batchid); $bn->setMIDQID($miid[$i]); $bn->setQuantity($mqty[$i]); $bn->setHeatCode($hcode[$i]); $bn->saveQtyDetails(); $i++; } } else { if (isset($_POST['Batch_ID'])) { // print_r($_POST);