I have a form which I want to be auto-completed with data from a table I made. How can I achieve this?
This is my table:
while($row = mysqli_fetch_assoc($result))
{
echo "<tr>";
echo "<td>" . $row['ID_Angajati'] . "</td>";
echo "<td>" . $row['Nume'] . "</td>";
echo "<td>" . $row['Prenume'] . "</td>";
echo "<td>" . $row['CNP'] . "</td>";
echo "<td>" . $row['Data_Nasterii'] . "</td>";
echo "<td>" . $row['Sex'] . "</td>";
echo "<td>" . $row['Numar_Telefon'] . "</td>";
echo "<td>" . $row['Salariu'] . "</td>";
echo "<td class = container_update ><button type = 'button' onclick = 'yes_js_modal();'>Update</a></td>";
echo "<td class = container_delete ><a href = 'includes/delete.php?id=$row[ID_Angajati]'>×</a></td>";
echo "</tr>";
}
echo "</table>";
And this is my form:
<form action="" method="POST">
<table align="center">
<tr>
<td>ID_Angajati:</td>
<td><input type = "text" name="ids" required></td>
</tr>
<tr>
<td>Nume:</td>
<td><input type = "text" name="nume" required></td>
</tr>
<tr>
<td>Prenume:</td>
<td><input type = "text" name="prenume" required></td>
</tr>
<tr>
<td>CNP:</td>
<td><input type = "text" name="cnp" required></td>
</tr>
<tr>
<td>Data Nasterii:</td>
<td><input type = "text" name="data" required></td>
</tr>
<tr>
<td>Sex:</td>
<td><input type = "text" name="sex" required></td>
</tr>
<tr>
<td>Numar Telefon:</td>
<td><input type = "text" name="nr_telf" required></td>
</tr>
<tr>
<td>Salariu:</td>
<td><input type = "text" name="sal" required></td>
</tr>
<tr>
<td colspan = "2" align = "center">
<input type="submit" id="button" name="submit" value="Update Details"></a>
</td>
</tr>
</table>
</form>
I want for instance ID_Angajati from my form to be auto-completed in the form with the value of one of my rows in the table. This will happen when I click on the “Update” button from the table.