not sure what I'm doing wrong: Trying to use array in POST to post to second table - seems I am messing up my arrays?

example below shows my php insert and the output I'm getting from the sql print, and var\_dump - looks like my POST array are not setup for the correct elements?

PHP:

```
$sql = "insert into invoice_details (NULL, product, disc, cost, quantity, price) values";
for($i=0; $i<sizeof($_POST);$i++){
    if(($i+1) == sizeof($_POST)){
        $sql .="('$id','$_POST[$i][item_number]','$_POST[$i][item_name]','$_POST[$i][item_desc]','$_POST[$i][item_qty]','$_POST[$i][item_cost]','$_POST[$i][item_price]')";
    }else{
        $sql .="('$id','$_POST[$i][item_number]','$_POST[$i][item_name]','$_POST[$i][item_desc]','$_POST[$i][item_qty]','$_POST[$i][item_cost]','$_POST[$i][item_price]'),";
    }
}

$query1 = sprintf($sql);
print $query1;
//$result1 = mysql_query($query1);

```

Results of POST:

```
array(11) {
    ["address"]=> string(132) " MyStreet Drive MyCity, XY 12345 Phone: (000) 555-1212"
    ["customer"]=> string(46) "Customer Name Address 1 Address 2 Address 3"
    ["invoice"]=> string(8) "20170212"
    ["item_desc"]=> array(2) { 
        [0]=> string(40) "Business Rate: Consulting/Labor/Installs" 
        [1]=> string(43) "Residential Rate: Consulting/Labor/Installs"
    }
    ["item_cost"]=> array(2) { 
        [0]=> string(7) "$150.00"
        [1]=> string(6) "$95.00"
    }
    ["item_qty"]=> array(2) {
        [0]=> string(1) "3"
        [1]=> string(1) "3"
    }
    ["xdate"]=> string(0) ""
    ["sales"]=> string(0) ""
    ["owed"]=> string(0) ""
    ["deducted"]=> string(0) ""
    ["PHPSESSID"]=> string(26) "2rd71183clcia54mb5o0q35j13"
} 

```

```sql
INSERT INTO invoice_details (NULL, product, disc, cost, quantity, price)
VALUES  ('29','[item_number]','[item_name]','[item_desc]','[item_qty]','[item_cost]','[item_price]'),
('29','[item_number]','[item_name]','[item_desc]','[item_qty]','[item_cost]','[item_price]'),
('29','[item_number]','[item_name]','[item_desc]','[item_qty]','[item_cost]','[item_price]'),
('29','[item_number]','[item_name]','[item_desc]','[item_qty]','[item_cost]','[item_price]'),
('29','[item_number]','[item_name]','[item_desc]','[item_qty]','[item_cost]','[item_price]'),
('29','[item_number]','[item_name]','[item_desc]','[item_qty]','[item_cost]','[item_price]'),
('29','[item_number]','[item_name]','[item_desc]','[item_qty]','[item_cost]','[item_price]'),
('29','[item_number]','[item_name]','[item_desc]','[item_qty]','[item_cost]','[item_price]'),
('29','[item_number]','[item_name]','[item_desc]','[item_qty]','[item_cost]','[item_price]'),
('29','[item_number]','[item_name]','[item_desc]','[item_qty]','[item_cost]','[item_price]')

```