<?php
try{
include("dbconnectie.php");
$query = $db->prepare("SELECT * FROM shop WHERE id_u = :id");
$query->bindParam("id", $_SESSION['id_u']);
$query->execute();
$result = $query->fetchALL(PDO::FETCH_ASSOC);
echo "<table>";
foreach($result as &$data) {
echo "<tr>";
$img = $data['img_url'];
echo "<td>" . $data["brand"] . "</td>";
echo "<td>" . $data["model"] . "</td>";
echo "<td> Condition: " . $data["cond"] . "/100 </td>";
echo "<td> Prijs: $ " . number_format($data["price"],2,",",".") . "</td>";
echo "<td> <img src='$img' width='400' height='300' ></img> </td>";
echo "<td>" . "<form method="post" action"">" .
"<input type="submit" name="delete" value="$data['id_img']">" . "</form>" . "</td>";
echo "</tr>";
}
echo "</table>";
} catch(PDOException $e) {
die("Error!: " . $e->getMessage());
}
?>
<html>
<body>
</body>
</html>
on line 17 and line 18 i'm trying to make a button for every time it loops so that i can delete those posts out of my database, but i'm unsure on how to make it loop the button making because it doesn't work how i wrote it.
echo "<td>" . "<form method='post' action=''>" . "<input type='submit' name='delete' value={$data['id_img']}>" . "</form>" . "</td>";