我似乎无法创建删除按钮来从我的数据库中删除特定项目。 我已经创建了一个数据库来存储图像表中的图像:
图像将显示在我的shop.php中,从那里,我想创建一个删除按钮,我可以从数据库中删除图像。
我的shop.php片段:
<?php
while ($row = mysqli_fetch_array($result))
{
echo "<div class='col-sm-4'>";
echo "<div class='product-image-wrapper'>";
echo "<div class='single-products'>";
echo "<div class='productinfo text-center'>";
echo "<div id='img_div'>";
echo "<img height='250' src='images/".$row['image']."' >";
echo " <h2>$56</h2>";
echo "<p>".$row['image_text']."</p>";
echo "</div>";
echo "<div class='choose'>";
echo "<ul class='nav nav-pills nav-justified'>";
echo "<li><a href=''><i class='fa fa-plus-square'></i>Add to wishlist</a></li>";
//echo "<li><a href=''><i class='fa fa-times'></i>Delete</a></li>";
echo "<li><a href='delete.php?id=" . $row['id'] . "'><i class='fa fa-times'></i>Delete</a></li>";
echo "</ul>";
echo "</div>";
echo "</div>";
echo "</div>";
echo "</div>";
echo "</div>";
}
?>
这是我的delete.php:
<?php
if (is_int($_GET["id"]) {
$query = "DELETE FROM images WHERE id = " . $_GET["id"];
$result = mysqli_query($con, $query);
// Check the result and post confirm message
}
?>