What you should do is pass an array of data via POST/GET.
To do this in your inputs, you make the name value = qty[]
for each input. Note the array syntax []
here.
PHP will automatically take all values for input with that array syntax and build an array out of it in $_POST/$_REQUEST.
So you would be able to access your array like
var_dump($_POST['qty']);
var_dump($_REQUEST['qty']);
That however still doesn't give the ability to match this to the price/pn as you need. So, let's take the array syntax one step further and actually put a key value in it like this:
<input name="qty[0]" ... />
<input name="qty[1]" ... />
By doing this you will be able to know exactly which array index matches which item (assuming you know the order the inputs were displayed in).
The would make $_POST['qty'][0]
be the first item, $_POST['qty'][1]
be the next and so on.
So assuming you also have you prices/pn in an array like this:
$item_array = array(
0 => array('price' => 123, 'pn' = 'ABC'),
1 => array('price' => 456, 'pn' = 'XYZ'),
...
);
You could then easily loop through the input quantities and build you final array like this:
$itemdetails = array();
foreach ($_REQUEST['qty'] as $key => $value) {
$itemdetails[$key] = $item_array[$key];
$itemdetails[$key]['qty'] = $value;
)
Also note, that if you are expecting this data to be passed via POST, it is considered best practice to use the $_POST
superglobal rather than the $_REQUEST
superglobal.