How to modify and delete two tables at the same time?

0

Good afternoon, I need your help, I am trying to delete and modify two tables at the same time I append the code that I am using; I hope and you can help me since it is difficult for me to do it, I would appreciate it:) ....

Functions.php

<?php
class revista{
    public function conecta($modo = "local"){
        $servername = "localhost";
        if ($modo == "local") {
            $username = "root";
            $password = "";
            $dbname = "revista";
        }elseif ($modo == "web") {
            $username = "";
            $password = "";
            $dbname = "";
        }

        $conn = new mysqli($servername, $username, $password, $dbname);
        if ($conn->connect_error) {
            die("Error de conexión: " . $conn->connect_error);
        }
        return  $conn;
    }

    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);
    }
}
?>

index.html

<section class="contenido">
    <div class="container">
        <div class="row">
            <h3 class="titulo1">Revistas</h3>
            <p class="descripcion">Dentro de está interfaz el administrador podrá consultar, actualizar y eliminar cada una de las revistras que se encuentran publicadas.</p>
            <hr><br>
        <div class="col-lg-3"></div>
            <div class="col-lg-6">
          <table class="table table-bordered">
            <tbody>
              <tr>
               <th class="col-md-8 encabezados">NO. REVISTA</th>
               <th class="col-md-2 encabezados">MODIFICAR</th>
               <th class="col-md-2 encabezados">ELIMINAR</th>
              </tr>

              <tr>
                <td>Nombre de la revista</td>
                <td><center><a class="gb-thick-border1" href="editar.php?id_revista=<?php echo $row->id_revista; ?>"><i class="fa fa-pencil fa-lg" aria-hidden="true"></i></a></center>EDITAR</td>
                <td><center><a class="gb-thick-border1" href="borrar.php?id_revista=<?php echo $row->id_revista;?>"><i class="fa fa-trash-o fa-lg" aria-hidden="true"></i></a></center>ELIMINAR</td>
              </tr>
              <?php } ?>
            </tbody>
          </table><br><br>
          <center><a class="gb-thick-border" href="index.php">Agregar una revista nueva</a></center>
        </div>      
      </div>
    </div>
  </section>

I hope for your help, thank you very much ...

    
asked by R.C. Ana 04.12.2017 в 20:04
source

1 answer

1

We assume that we have two Tables in our database. Invoice and Users. We will update both tables at the same time using the statement INNER JOIN of SQL.

SELECT Factura.columName, Usuarios.columName
FROM Factura
INNER JOIN Usuarios ON Factura.columnName = Usuarios.columName;

Inner Join Returns only those records / rows that have identical values in the two fields that are compared to join both tables. That is, those that have elements in the two tables, identified by the field of relationship.

    
answered by 05.12.2017 в 11:37