From 1c5f7d42c126822f23d0e0b158ea0a6f6df41fd9 Mon Sep 17 00:00:00 2001 From: Andreas Zweili Date: Tue, 7 Mar 2017 20:29:02 +0000 Subject: [PATCH] fix the delete function --- functions.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/functions.php b/functions.php index d0305d9..cb882d3 100644 --- a/functions.php +++ b/functions.php @@ -206,9 +206,17 @@ function delete_demand() /* assign the variable with data from the delete button */ $demandId = $_POST['demandId']; + /* Delete all the offers corresponding to the demandId + from the database */ + $delete_offers_query = "DELETE FROM offers WHERE demandId='$demandId'"; + $delete_offers_result = mysqli_query($con, $delete_offers_query) + or die(mysqli_error($con)); + // Delete the demand matching the demandId from the database - $sql = "DELETE FROM demands WHERE demandId='$demandId'"; - $result = mysqli_query($con, $sql) or die(mysqli_error($con)); + $delete_demand_query = "DELETE FROM demands WHERE demandId='$demandId'"; + $delete_demand_result = mysqli_query($con, $delete_demand_query) + or die(mysqli_error($con)); + header('Location: board.php'); } }