I have a MySql table:
id concept
-------------
1 item1
2 item2
3 item3
I try to generate this table dynamically in the hmtl (I am not sure if I did it well):
<form action="extern.php" method="post">
<?php
$result = mysqli_query($con, 'SELECT * FROM MyTable');
while ($row = mysqli_fetch_array($result)) {
?>
<input type="text" name="<?php echo $row["concept"] ?>"
value="<?php echo $row["concept"] ?>"><br>
<?php
}
?>
<input type="submit">
</form>
This gives in the source of the html:
<form action="extern.php" method="post">
<input type="text" name="item1" value="item1"><br>
<input type="text" name="item2" value="item2"><br>
<input type="text" name="item3" value="item3"><br>
<input type="submit" name="send">
</form>
Then I put the php in the extern.php. And here comes my question:
How can I know the id of each input to match the concept in the update?
$id = $_POST["something"]; // how should I do this var?
$concept = $_POST["something"]; // how should I do this var?
mysqli_query($con,"UPDATE MyTable
SET concept = '$concept'
WHERE id = $id");
(I am sorry if this question is too basic. I really have tried a lot of things and look a lot of places. I am learning. Any help would be appreciated)