Hello
Below is my code.
Each row has transactionId and submit button.
As you may guess, I would like to pass "transactionId" of the row to itemReturned.php when itemReturned submit button of that row is pressed.
So I used "hidden" input type, but as you see the hidden input type "transactionId" value always is the last one.
Of course in itemReturned.php file, I need to retrieve the transaction id value and insert into DB.
So when I use $_POST[transactionId] to get the hidden value in itemReturned.php,
it always shows the last transaction id of the do() while loop.
No wonder because it loops and assign the last id to the transactionId.
Now how can I pass individual id when individual submit button is pressed?
Below is my code.
PHP:
<?php
$borrowUserId = userId();
$sql = "SELECT transaction.id as id, itemReturned, itemReturnedDate
FROM transaction
WHERE borrowUserId = '$borrowUserId' ";
if ($shouldReturn = mysql_fetch_array($shouldReturns)) {
echo '<p>Hello, '. $username . '! Here are items you should return.</p>';
echo '<form method="post" action="itemReturned.php">';
echo '<table border="1" cellpadding="1" cellspacing="0">';
$i = 1;
do {
$id = $shouldReturn['id'];
$returnByDate = $shouldReturn['returnByDate']; $itemReturned = $shouldReturn['itemReturned'];
$itemReturnedDate = $shouldReturn['itemReturnedDate'];
echo '<tr><td><input type="hidden" name="transactionId" value="'.$id.'">';
if ($itemReturned) {
echo '<td><font color="#ff0000"> returned </font></td>';
echo '<td>'.$itemReturnedDate.'</td></tr>';
} else {
echo '<td><font color="#C0C0C0"> not yet </font></td>';
echo "<td><script>DateInput('itemReturnedDate', true, 'YYYY-MM-DD')</script>";
echo '<input type="submit" name = "itemReturned" value="Item Returned" /></td>';
}
$i++;
} while ($shouldReturn = mysql_fetch_array($shouldReturns));
echo "</table></form>";
}
?>
Each row has transactionId and submit button.
As you may guess, I would like to pass "transactionId" of the row to itemReturned.php when itemReturned submit button of that row is pressed.
So I used "hidden" input type, but as you see the hidden input type "transactionId" value always is the last one.
Of course in itemReturned.php file, I need to retrieve the transaction id value and insert into DB.
So when I use $_POST[transactionId] to get the hidden value in itemReturned.php,
it always shows the last transaction id of the do() while loop.
No wonder because it loops and assign the last id to the transactionId.
Now how can I pass individual id when individual submit button is pressed?