this is the var_dump($_POST) :
array(18) { ["_token"]=> string(40) "Qg0krYddkI2cnPQBy5T3yGJdQqRBbb9q173MXzoa" ["from_name"]=> string(2) "4r" ["from_address"]=> string(1) "4" ["invoice_id"]=> string(1) "4" ["invoice_date"]=> string(0) "" ["due_date"]=> string(0) "" ["to_name"]=> string(1) "4" ["to_address"]=> string(1) "4" ["item"]=> array(1) { [0]=> string(5) "Hours" } ["desc"]=> array(1) { [0]=> string(2) "44" } ["unitAmt"]=> array(1) { [0]=> string(1) "4" } ["qty"]=> array(1) { [0]=> string(1) "4" } ["amount"]=> array(1) { [0]=> string(2) "16" } ["invoiceNotes"]=> string(2) "44" ["subTotal"]=> string(2) "16" ["total"]=> string(2) "16" ["amtPaid"]=> string(1) "0" ["balDue"]=> string(2) "16" }
As you can see the variable unitAmt is being posted, but I am getting this error when I use it :
ErrorException
Undefined index: unitAmt
open: /var/www/lk/htdocs/app/routes.php
//var_dump($rows);
//var_dump($description);
for($i=0; $i<count($rows);$i++){
DB::table('item_description')->insert(
array('invoice_id' => $returnID, 'item' => $rows[$i], 'description' => $description[$i],
'unit_price' => $_POST['unitAmt'][$i], 'quantity' => $_POST['qty'][$i], 'amount'=>$_POST['amount'][$i]));
}
This works fine for qty and amount which are posted similarly. Same thing is happening at other places also on dumping a variable I can see data is there but when I use it shows undefined index.
Edit : THis is my code in route.php
var_dump($_POST);
$rows = $_POST['item'];
$description = $_POST['desc'];
for($i=0; $i<count($rows);$i++){
DB::table('item_description')->insert(
array('invoice_id' => $returnID, 'item' => $rows[$i], 'description' => $description[$i],
'unit_price' => $_POST['unitAmt'][$i], 'quantity' => $_POST['qty'][$i], 'amount'=>$_POST['amount'][$i]));
}