Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Código:
- //Índice principal.
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <meta http-equiv="X-UA-Compatible" content="ie=edge">
- <title>Formulario PHP/SQL/HTML</title>
- </head>
- <body>
- <?php
- error_reporting(0);
- require('displayTabla.php');
- $dbList = $_REQUEST['basesDatos'];
- $server = "localhost";
- $user = "root";
- $pass = "";
- $mysqli_db = new mysqli($server, $user, $pass);
- $mysqli_lb = new mysqli($server, $user, $pass, $dbList);
- $query1 = mysqli_query($mysqli_db, "SHOW DATABASES");
- $query2 = mysqli_query($mysqli_lb, "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA ='$dbList';");
- ?>
- <h1>Visor dinámica de tablas</h1>
- <form action="Ejercicio3.php" method="get">
- <label>Base de datos</label>
- <select name="basesDatos">
- <option value=<?php echo $dbList; ?> selected>-Elige una BBDD-</option>
- <?php
- while ($row = mysqli_fetch_array($query1)) {
- $rawdata = $row[0];
- echo "<option value=$rawdata>$rawdata</option>";
- }
- ?>
- </select>
- <input type="submit" value="Seleccionar BD" name="seleccionaBD">
- </form>
- <form action="Ejercicio3.php" method="get">
- <label>Base de datos</label>
- <select name="listBases">
- <option value="" selected disabled hidden>-Elige una tabla-</option>
- <?php
- while ($row = mysqli_fetch_array($query2)) {
- $rawdata = $row[0];
- echo "<option value=$rawdata>$rawdata</option>";
- }
- ?>
- </select>
- <input type="submit" value="Seleccionar tabla" name="seleccionaLB">
- <hr>
- <?php
- $table = $_REQUEST['listBases'];
- displayTable($table);
- ?>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement