I am passing a table data value within a for each loop to the php script. The problem here is that when I try to echo $exchange;
. I don't get any values of the specific product name. The product name being displayed in the form is item1.
<form action="exchangeItem" method="post">
<tbody>
<?php
$query = "SELECT * FROM product";
$data = $MySQLi_CON->query($query);
foreach ($data as $key ) {
?>
<tr>
<td class="id"><h3><input type="hidden" name="productName" ><?php echo $key['product_Name'];?></h3>
</td>
<input name = "id" type = "hidden" value="<?php echo $id; ?>">
<td id="exchange_button">
<input value="Exchange" name="exchange_submit" type="submit" class="btn btn-primary btn-md raised exchange_submit">
</td>
</tr>
<?php
}
?>
</tbody>
</form>
exchangeItem.php
<?php
$exchange = $_POST['productName'];
echo $exchange;
exit;
?>