I have a database with many tables. On side 1, I have a button that passes me to side 2. On side 2, I want the code to remove every row in every named table that has a specific pid
that I have stored in a variable. I have a code on side 2 but it doesn't do anything.
Code on side 2:
$pid3 = $_POST['pid2'];
$del = "DELETE FROM answer_det WHERE pid='$pid3'";
$del .= "DELETE FROM project WHERE pid='$pid3'";
$del .= "DELETE FROM question WHERE pid='$pid3'";
$del .= "DELETE FROM respondent WHERE pid='$pid3'";
$del .= "DELETE FROM result WHERE pid='$pid3'";
$del .= "DELETE FROM users WHERE pid='$pid3'";
$run = mysqli_query($mysqli,$del);
if($run)
{
echo "Project is deleted!
";
}
Answer
$pid3 = $_POST['pid2'];
$del = "DELETE FROM answer_det WHERE pid='$pid3';";
$del .= "DELETE FROM project WHERE pid='$pid3';";
$del .= "DELETE FROM question WHERE pid='$pid3';";
$del .= "DELETE FROM respondent WHERE pid='$pid3';";
$del .= "DELETE FROM result WHERE pid='$pid3';";
$del .= "DELETE FROM users WHERE pid='$pid3';";
$run = mysqli_multi_query($mysqli,$del);
if($run)
{
echo "Project is deleted!
";
}
No comments:
Post a Comment