How to Merge Multiple Variables and Loop them

I’m having a problem on deleting database table column values. I made selection on different table with different variable. like this

    $queryben = $mysqli->query("SELECT * FROM tblbeneficiaries ORDER BY id ASC");
    $querycom = $mysqli->query("SELECT * FROM tblcomaker ORDER BY id ASC");
    $querycus = $mysqli->query("SELECT * FROM tblcustomers ORDER BY id ASC");
    $querycusin = $mysqli->query("SELECT * FROM tblcustomersinfo ORDER BY id ASC");
    $queryll = $mysqli->query("SELECT * FROM tbllandlord ORDER BY id ASC");
    $querypar = $mysqli->query("SELECT * FROM tblparents ORDER BY id ASC");
    $querypro = $mysqli->query("SELECT * FROM tblproperty ORDER BY id ASC");
    $queryspou = $mysqli->query("SELECT * FROM tblspouse ORDER BY id ASC");

Then I’m trying to delete them but I have a problem whenever I choose only one query.

if(isset($_POST['delete'])){
      $deleteData = $mysqli->query("DELETE FROM tblbeneficiaries WHERE salt='$_POST[hidden]'");
      $deleteData = $mysqli->query("DELETE FROM tblcomaker WHERE salt='$_POST[hidden]'");
      $deleteData = $mysqli->query("DELETE FROM tblcustomers WHERE salt='$_POST[hidden]'");
      $deleteData = $mysqli->query("DELETE FROM tblcustomersinfo WHERE salt='$_POST[hidden]'");
      $deleteData = $mysqli->query("DELETE FROM tbllandlord WHERE salt='$_POST[hidden]'");
      $deleteData = $mysqli->query("DELETE FROM tblparents WHERE salt='$_POST[hidden]'");
      $deleteData = $mysqli->query("DELETE FROM tblproperty WHERE salt='$_POST[hidden]'");
      $deleteData = $mysqli->query("DELETE FROM tblspouse WHERE salt='$_POST[hidden]'");
}

My while loop for query

while($objcus = $querycus->fetch_object()){
<form action="#" method="POST">
...
</form>
<input type="hidden" name="hidden" value="'.$objcus->salt.'">
}

Please help me to delete the queries on the other table. I can only delete in the tblcus. I’m trying find a way on how can I merge different table in one query but I can’t see better and simple info.
Please help me


Source: php

Leave a Reply