I’m trying to create a function that removes a row from the database once an image is clicked, so far the code works in identifying the order needing to be removed however when I go to use the post function it doesn’t respond in any way. No error no nothing and I can’t see to figure it out, any help would be appreciated.
<script>
$(document).ready(function() {
$('.bins').click(function() {
var name = $(this).attr('name');
alert(name);
$.post("cancel.php", {cancels: name})
alert("bruh moment");
});
});
</script>
while ($row = mysqli_fetch_assoc($result)){
$order_advanced = implode(",", $row);
$order = $row["Order_ID"];
$colour = $row["Colour_Custom"];
$Ingredient = $row["Ingredients"];
$amount = $row['Order_amount'];
$photo = "rubbish.png";
$_SESSION['Current'] = $order;
echo "
<tr>
<td>$order</td>
<td>$colour</td>
<td>$Ingredient</td>
<td>$amount</td>
<td><img name = $order id="rubbish" src="rubbish.png" class="bins"></td>
</tr>"
}
<?php
if($_SERVER['REQUEST_METHOD'] == "POST") {
header("Location: account.php");
include("database.php");
include("functions.php");
$order = $_POST['cancels'];
$query = "delete from designs where Order_ID = '$order' limit 1";
mysqli_query($con, $query);
header("Location: orders.php");
die;
}
?>