I am having a issue in getting the correct value from the table
.
The issue I encountered:
- When I choose the second
checkbox
the and input aquantity
, it is Undefined offset: 0
But the value of the checkbox
is working and correct.
What I am expecting is when I choose the second or other checkbox
(exclude first checkbox
), I should get the value of that input field.
HTML
<?php foreach($results as $row) { ?>
<tr>
<td><input type="checkbox" name="products[]" value="<?php echo $row->items_id; ?>"></td>
<td><?php echo $row->item_name; ?></td>
<td><input type="number" name="quantity[]" class="form-control"></td>
</tr>
<?php } ?>
<input type="submit" name="process" class="btn btn-primary" value="Process">
PHP
$quantity = $_POST['quantity'];
$products = $_POST['products'];
$count_selected = count($products);
for($i=0; $i< $count_selected; $i++){
var_dump($quantity[$i]); exit;
}