Just trying some different stuff and run into this problem. I'm echoing out some different table values onto an example site, then from a dropdown menu i want to change the data from lets say 1 to 2. I'm just using a post form action to do it, but the problem is how do i get the ID of this exact row with the dropdown menu, when i got 10 different rows that are outputed? Atm I only change all the row values from 1 to 2 when i use this code:
PHP
if (isset($_POST['insert2']))
{
$status2 = $_POST['status2'];
$sql2 = ("UPDATE test3 SET status='$status2' WHERE id=id");
if (mysqli_query($conn, $sql2)) {
header("Location: index.php");
exit;
} else {
echo "Error: " . $sql2 . "<br>" . mysqli_error($conn);
}}
HTML with echo
<?php while($row = mysqli_fetch_assoc($result)) { echo
'<div class="box">
<div class="box-id">
<p class="box-id-text">Bonus id: ' . $row ['id'] . '</p>
</div>
<div class="box-date">
<p class="box-date-text">Date laget: ' . $row ['date'] . '</p>
</div>
<div class="box-status">
<div class="box-endre-status">
<p class="box-status-text">Status: Pending,</p>
<form action="" method="post">
<select name="status2" class="endre-status">
<option value="" disabled selected>Endre status</option>
<option value="1">1</option>
<option value="2">2</option>
</select>
<input type="submit" name="insert2" value="Oppdater">
</form>
</div>
</div>
</div>';}?>
Very new to this and would be very much appreciated if someone can help me in the right direction.