I have a switch case where I check for $_Get['p']
where p
will either be yes
or no
and in this case yes
will unlink a file from folder.
If unlink is success it will also delete records from two tables where title is the common column in both tables. Right now im deleting from both tables with 2 queries.
How could I do this with one query? I tried outer join but I could't really grasp it. I got select working with left join however when I try to delete using left/right join I can´t get it working.
if(isset($_GET['p'])){
switch($_GET['p']) {
case 'yes':
$data= $_GET['data'];
$remove= unlink("upload/test.txt");
if($remove){
echo "test.txt Have been successful deleted from folder.";
$delete = mysqli_query($conn,"DELETE FROM testdoc WHERE title='$data'");
$delete2 = mysqli_query($conn,"DELETE FROM testcheck WHERE title='$data'");
}
break;
case 'no':
header("index.php");
exit();
break;
}
}
This is the code I tried to use when deleting from 2 tables using RIGHT join.
DELETE
FROM testdoc
RIGHT JOIN testcheck
ON testdoc.title = testcheck.title WHERE testcheck.title='$data'
I know I'm vulnerable to SQL injection(s) at the moment, I want things to work before I prepare for attacks from SQL injections.