Sample Header Ad - 728x90

Deleting rows from multiples tables at once

0 votes
3 answers
48 views
I have a question about this piece of code I just wrote. I have a problem with the syntax, the first query executes its purpose, the problem is in the second query which does not.
if(isset($_POST['deletecontr'])){
  $dcquery = $_POST['dni']; // This get the ID of the person who I want to delete.
  $catchempr = ("SELECT empresa FROM contratistas WHERE dni='$dcquery'"); //This catch the name of the company of that person
  $query = ("DELETE FROM contratistas WHERE dni='$dcquery'"); // This works fine
  $query2 = ("DELETE FROM empleados WHERE empresa='$catchempr'"); This does not.
  mysqli_query($link,$query);
  mysqli_query($link,$query2); 
  echo "La empresa a sido eliminada de la base de datos";
I hope you guys can see something that I'm not seeing.
Asked by jpmer (11 rep)
Feb 23, 2020, 04:08 PM
Last activity: Feb 27, 2020, 02:51 PM