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'); } }