I need to link each value(id) to an amount for making some calculations but I can't figure out how this could work. This is my code:
HTML
<select name="type[]">
<option value="id">...</option>
</select>
<input name="amount"/>
//This repeats with a loop 8 times. There are 8 select boxes with the same options.
PHP
$type = $_POST['type'];
$id = $_POST['id'];
$amount = $_POST['amount'];
foreach ($products as $thisProduct) {
foreach ($id as $value) {
if ($thisProduct->getId() == $value) {
$multiply = ($thisProduct->getMultiply($amount));
array_push($array, $multiply);
}
switch($type){
case "one":
$multiplyType = ($thisProduct->getMultiplyType($amount));
array_push($arrayType, $multiplyType);
break;
case "two":
$multiplyType = ($thisProduct->getMultiplyType($amount));
array_push($arrayType, $multiplyType);
break;
case "three":
$multiplyType = ($thisProduct->getMultiplyType($amount));
array_push($arrayType, $multiplyType);
break;
}
}
}
This works but the values get multiplied with the last <input>. So when the last input value = 10, all the values get multiplied by 10. What is the simplest way to link each input to a specific select element?