I am trying to pass the value of <input id="ids" type="hidden" name="ids" value="<?php echo $key['product_ID'];?>"> to the exchange.php page. Lets say i have apple | 1 , orange | 2, pineapple | 3. However, whenever i try to submit the values to another page, I am getting the 3 as the echo value of $product. When i try to remove the type="hidden", I get the correct value but when I try to submit, it turns out to be a different value.
<form action="exchange.php" method="post">
<div class="row">
<?php $query="SELECT * FROM Product" ; $data=$ MySQLi_CON->query($query);
foreach ($data as $key ) { ?>
<strong>Name: </strong>
<?php echo $productname=$ key[ 'product_Name'];?>
<input id="ids" type="hidden" name="ids" value="<?php echo $key['product_ID'];?>">
<strong>Status: </strong>
<strong>Action: </strong>
<input type="submit" value="Exchange" name="exchange_submit" class="btn btn-info btn-xs">
<input id="id" name="id" type="hidden" value="<?php echo $id; ?>">
<?php } ?>
</div>
</form>
exchange.php
<?php
$id = $_POST['id'];
$product = $_POST['ids'];
echo $id;
echo $product;
exit;
?>