My add_id is a primary key. I have displayed all the addresses from the same cus_id but with different add_id. I want to delete a specified row of address but when I press the delete button, the page refresh but no data was deleted. Please look at my codes, thank you.
These are the codes involved, and my db:
<?php
$cus_id = $_SESSION['id'];
//To show all the addresses with the same cus_id
$result2 = mysqli_query($connect, "SELECT * FROM customer_address WHERE cus_id='$cus_id'");
?>
<?php
if (isset($_GET['del'])) {
  $add_id = $_GET["id"];
  mysqli_query($connect, "DELETE FROM customer_address WHERE add_id='$add_id'");
}
?>
<?php
while ($row1 = mysqli_fetch_assoc($result2)) {
?>
  <div class="addrow">
    <div class="add_box">
      <p id="name_row"><?php echo $row1['name']; ?> </p>
      <p id="phone_row"><?php echo $row1['contact']; ?> </p>
      <p id="add_row"><?php echo $row1['address']; ?></p>
    </div>
    <div class="btn_box">
      <input type="button" name="editbtn" class="editbtn" value="Edit">
      <a href="cus_address.php?del&id=<?php echo $row['cus_id']; ?>"><input type="button" name="deletebtn" class="deletebtn" value="Delete"></a>
      <input type="button" name="defaultbtn" class="defaultbtn" value="Set As Default">
    </div>
  </div>
<?php
}
?>
<?php
if (isset($_GET['del'])) {
  $add_id = $_GET["id"];
  mysqli_query($connect, "DELETE FROM customer_address WHERE add_id='$add_id'");
  echo ("<script>location.href = 'cus_address.php?msg=$msg';</script>");
}
?>

 
     
    