Advertisement
Guest User

Untitled

a guest
Sep 25th, 2018
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. Código:
  2.  
  3. //Índice principal.
  4. <!DOCTYPE html>
  5. <html lang="en">
  6. <head>
  7. <meta charset="UTF-8">
  8. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  9. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  10. <title>Formulario PHP/SQL/HTML</title>
  11. </head>
  12. <body>
  13.  
  14. <?php
  15. error_reporting(0);
  16. require('displayTabla.php');
  17.  
  18. $dbList = $_REQUEST['basesDatos'];
  19.  
  20. $server = "localhost";
  21. $user = "root";
  22. $pass = "";
  23.  
  24. $mysqli_db = new mysqli($server, $user, $pass);
  25. $mysqli_lb = new mysqli($server, $user, $pass, $dbList);
  26.  
  27. $query1 = mysqli_query($mysqli_db, "SHOW DATABASES");
  28. $query2 = mysqli_query($mysqli_lb, "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA ='$dbList';");
  29. ?>
  30.  
  31. <h1>Visor dinámica de tablas</h1>
  32.  
  33. <form action="Ejercicio3.php" method="get">
  34. <label>Base de datos</label>
  35. <select name="basesDatos">
  36. <option value=<?php echo $dbList; ?> selected>-Elige una BBDD-</option>
  37. <?php
  38. while ($row = mysqli_fetch_array($query1)) {
  39. $rawdata = $row[0];
  40. echo "<option value=$rawdata>$rawdata</option>";
  41. }
  42. ?>
  43. </select>
  44. <input type="submit" value="Seleccionar BD" name="seleccionaBD">
  45. </form>
  46.  
  47. <form action="Ejercicio3.php" method="get">
  48. <label>Base de datos</label>
  49. <select name="listBases">
  50. <option value="" selected disabled hidden>-Elige una tabla-</option>
  51. <?php
  52. while ($row = mysqli_fetch_array($query2)) {
  53. $rawdata = $row[0];
  54. echo "<option value=$rawdata>$rawdata</option>";
  55. }
  56. ?>
  57. </select>
  58. <input type="submit" value="Seleccionar tabla" name="seleccionaLB">
  59. <hr>
  60. <?php
  61. $table = $_REQUEST['listBases'];
  62. displayTable($table);
  63. ?>
  64. </form>
  65. </body>
  66. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement