I created a system for post creation. But I'm not able to delete it in the bank but the confirmation of Successfully Deleted appears!
<?php
$db = mysqli_connect("127.0.0.1", "root", "", "photos");
$sql = "SELECT * FROM images";
$result = mysqli_query($db, $sql);
while ($row = mysqli_fetch_array($result)) {
echo "<div class='post-item'> <div class='inner'>";
echo " <div class='post-title'><h2><a href='#'> ".$row['titulo']."</a></h2></div>";
echo "<div class='post-image'><div></div><img src='images/".$row['image']."'></div ";
echo " <div class='post-meta-top'>Posted <span class='post-date'>2 days ago</span> </div>
<div class='clear'></div> ";
echo " <div class='post-desc'>
<p>".$row['texto']."</p>
</div>";
echo " <a href='?id=".$row['id']."&Acao=Deletar'><button>Deletar</button></a>
</div>
</div>";
}
if (isset($_GET['Acao']) && $_GET['Acao'] == 'Deletar') {
$id = $_GET['id'];
$sql = mysqli_query("DELETE FROM images WHERE id='$id' ");
if ($result) {
echo '<script type="text/javascript">alert("Comentario Excluido!"); </script>';
} else {
echo '<script type="text/javascript">alert("Erro!"); </script>';
}
}
?>