I have a page where I get values from the database in a table.
echo "<tr>";
echo "<th>Empresa</th>";
echo "<th>Categoria</th>";
echo "<th>Serviço</th>";
echo "<th>Descrição</th>";
echo "<th>Pagamento</th>";
echo "<th>Distrito</th>";
echo "<th>Investimento</th>";
echo "</tr>";
$numLinhas = 0;
while ($produto = mysql_fetch_array($produtos)) {
$numLinhas++;
echo "<tr class='table-hover'>";
//echo "<td>".$produto['id']."-".$numLinhas."º</td>";
echo "<td>autor:".$produto['user_of'] . "</td>";
echo "<td>".$produto['id'] . "</td>";
echo "<td>".$produto['categ'] . "</td>";
echo "<td>".$produto['titulo'] . "</td>";
echo "<td>".$produto['descricao'] . "</td>";
echo "<td>".$produto['valor'] . "</td>";
echo "<td>".$produto['local'] . "</td>";
echo "<td>".$produto['investimento'] . "</td>";
echo "<td><input style='width:40px' type='number' name='novo_investimento' value='0'><a href=up_invest.php?id=".$produto['id'].">
<input name='submit' type='submit' value='Ok'></a></td> ";
echo "</tr>";
}
echo "</table>";
In this same table I have an input number which I call 'new_investment'.
echo "<td><input style='width:40px' type='number' name='novo_investimento' value='0'><a href=up_invest.php?id=".$produto['id'].">
<input name='submit' type='submit' value='Ok'></a></td> ";
In the up_invest.php page, where the data is processed, I would like to get the line id and the new value defined by the user from the 'new_investment' field of this line.
The way it is, on the up_invest.php page when I do this
$id= $_REQUEST['id'];
$investimento=$_REQUEST['novo_investimento'];
echo "$id $investimento";
It just takes the id. How do I get the value of the field 'new_investment'?
Notice: Undefined index: novo_investimento
With the < form >
echo "<td><form action='up_invest.php' method='post'><input style='width:40px' type='number' name='novo_investimento' value='0'>
<input name='submit' type='submit' value='Ok'></form></td> ";
It takes the value of 'new_investment', but loses the id of the line. How do I get the id of the line where this form is presented?
Solved. I created a hidden field with the ID value of the line.
echo "<td><form id='form1' name='form1' action='up_invest.php' method='post'><input style='width:40px' type='number' name='novo_investimento' value='0'>
<input type='hidden' name='id' value=".$produto['id'].">
<input name='submit' type='submit' value='Ok'></form></td> ";