I've been stuck in this code where I should delete data from 3 tables using the client_accounts, with the same id of that specific user. this code doesn't delete and I need all your help, thank you.
<?php
include "connect.php";
$index = $_POST['index'];
$msg = [];
$sql = "DELETE client_accounts, ct_trans, ct_update
FROM client_accounts
LEFT JOIN ct_trans ON client_accounts.ct_id=client_accounts.client_id
LEFT JOIN ct_update ON client_accounts.ct_id=ct_update.ct_id
WHERE client_accounts.client_id = '$index';";
if($db->query($sql)){
$msg['status'] = true;
$msg['message'] = "Deleted Successfully";
}else {
$msg['status'] = false;
$msg['message'] = "Deletion Failed";
}
echo json_encode($msg);
?>
this is the jquery part
function deleteclient(i){
$.post("delclient.php",{"index":i},function(response){
var data = JSON.parse(response);
$("#message").text(data.message);
getclient();
})
}