I would like to delete data from two different tables in Mysql with PHP, I have the following tables;
Table Magazine
id_revista|no_revista|colaboradores|imagen |fecha_publicacion|archivo|clave
1 |No. 1 | Ana Luna |img.jpg |2017-12-06 |1.pdf |cb12
Table Article
id_articulo|articulo |autor |clave
1 |Vivir bien |Juan Sanches |cb12
the key of both tables is the same, which is saved without problem, to insert I use the following query;
public function registro($no_revista, $colaboradores, $fecha_publicacion, $imagen, $archivo, $articulo, $autor){
$sql = "INSERT INTO revista (no_revista, colaboradores, fecha_publicacion, imagen, archivo) VALUES ('$no_revista', '$colaboradores', '$fecha_publicacion', '$imagen', '$archivo')";
$consulta = $this->conecta()->query($sql);
$sql1 = "INSERT INTO articulos (articulo, autor)
VALUES ('$articulo', '$autor')";
$consulta = $this->conecta()->query($sql1);
How do I do it so that if I delete it from the magazine table, all the articles with the same key will be removed from the table?
I have two buttons to delete and update I would like to delete the insertion of the journal table and the table the inserted data that have the same key
and the button how can I add that function?