I have some table rows inside a while loop, the rows are all data from my database, each row has a submit button. I want to post specific data to another page, for example, if I press submit_3 then I want to post all data of row 3 to otherpage.php, but the way I tried it, it always uses the last row.
For example, I have 25 rows, then I submit button 3 and it will post all information from row 25.
print '<form method="POST" action="edit.php" name="action">';
//print '<input type="hidden" value="'.$imId.'" name="imId">';
print '<div class="tbl-content">';
print '<table cellpadding="0" cellspacing="0" border="0">';
print '<tbody>';
$querySelect = "select hersteller, name, kaufDatum, category, ablaufDatum, imID, details from inventoryManager ";
$querySelect .= $orderBy;
error_log( "SQL2:" . $querySelect . "<br>", 3, "C:/Control/log/debug/dp.html" );
$resultSelect = db_query( [ $querySelect ] );
while ( ( $row = mysql_fetch_array( $resultSelect ) ) ) {
$manufacturer = $row[ hersteller ];
$name = $row[ name ];
$buyDate = $row[ kaufDatum ];
$selectCategory = $row[ category ];
$expireDate = $row[ ablaufDatum ];
$imId = $row[ imID ];
$details = $row[ details ];
print '<tr>';
print "<td>$manufacturer</td>";
print "<td>$name</td>";
print "<td>$buyDate</td>";
print "<td>$selectCategory</td>";
print "<td>$expireDate</td>";
//error_log("imIdCheck#1:".$imId."<br>",3,"C:/Control/log/debug/dp.html");
print '<td><input type="submit" name="edit_' . $imId . '" value="Bearbeiten" class="button2 button3"></td>';
print '</tr>';
}
print '</tbody>';
print '</table>';
print '</div>';
print '</form>';
On the other page, I select all data with the $imId, but every time I press a submit button even if its submit_1 I get the last possible step. What do I have to include that it submits the data of the choosed row?
Edit: Some of the HTML-Code after implementing a suggestion to have a button:
<form method="POST" action="edit.php" name="action">
<div class="tbl-content">
<table cellpadding="0" cellspacing="0" border="0">
<tbody>
<tr>
<td>test</td>
<td>TestName</td>
<td>2019-03-23</td>
<td></td>
<td>2019-03-22</td>
<input type="hidden" value="2" name="imId">
<td>
<button type="submit" name="id" value="2" class="button2 button3">Bearbeiten</button>
</td>
</tr>
<tr>
<td>TestHersteller</td>
<td>TestName</td>
<td>2019-03-31</td>
<td></td>
<td>2019-03-31</td>
<input type="hidden" value="3" name="imId">
<td>
<button type="submit" name="id" value="3" class="button2 button3">Bearbeiten</button>