Im working on an older project. that needs a small fix with deleting a specific row from the database. There is a loop that retrieves images from the database and adds a delete button to it as well. but when i click the remove button it removes all the images instead of the image i click on. so if it retrieves 5 images. it removes 5 instead of 1 that i click on. ps.(don't hate about the older version of sql that's used pls :)
$result = mysqli_query($con, "SELECT selfies.ID, selfies.afbeelding FROM selfies");
while($row = mysqli_fetch_array($result)){
echo "<div class='results'>";
$image = $row['afbeelding'];
$image_src = "images/".$image;
echo "<img class='selfiess' src='$image_src'>";
echo "<br>";
echo "<form method='post'><button type='submit' value='".$row['ID']."' class='button special big' name='removeSel'>Remove</button></form><br><br>";
echo "</div>";
if (isset($_POST['removeSel'])){
$query = mysqli_query($con, "DELETE FROM selfies WHERE ID='".$row['ID']."' LIMIT 1");
$result2 = mysql_query($query);
header("Location: index.php?page=selfies");
}
}