SHARE
TWEET

Untitled

a guest Feb 4th, 2016 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. $hostname = "localhost";
  3. $username = "root";
  4. $password = "";
  5. $db = "db_12058661";
  6. ?>
  7.    
  8. <?php
  9.  
  10. require("db.php");
  11.  
  12. $id = $_GET['id'];
  13.  
  14. if ($id == 1){
  15. $query=new     PDO("mysql:dbname=$db;host=$hostname","$username","$password");
  16. $statement=$query->prepare("SELECT * FROM $id");
  17. $statement->execute();
  18. $results=$statement->fetchAll(PDO::FETCH_ASSOC);
  19. $json=json_encode($results);
  20. }
  21. ?>
  22.    
  23. <?php
  24. require_once("db.php");
  25.  
  26. $query=new PDO("mysql:dbname=$db;host=$hostname","$username","$password");
  27. $statement=$query->prepare("show tables");
  28. $statement->execute();
  29. $results=$statement->fetchAll(PDO::FETCH_ASSOC);
  30. $json = json_encode($results);
  31.  
  32. echo ($json);
  33.  
  34. ?>
  35.    
  36. <html>
  37. <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet">
  38. <script src="//code.jquery.com/jquery-1.10.2.min.js"></script>
  39. <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
  40. <nav class="navbar navbar-inverse">
  41. <div class="container">
  42. <div class="container-fluid">
  43. <div class="navbar-header">
  44.   <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
  45.   </button>
  46.   <a class="navbar-brand">Michael Delahorne 12058661</a>
  47. </div>
  48. <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
  49.   <ul class="nav navbar-nav">
  50.   </ul>
  51. </div>
  52. </div>
  53. </nav>
  54. <body>
  55. <div class="row">
  56. <div class="container">
  57.         <div class="col-md-12">
  58.                 <select name="options" id="options" class="form-control">
  59.                     <option value="0">Select</option>
  60.                     <option value="1">People</option>
  61.                     <option value="2">Animals</option>
  62.                     <option value="3">Shapes</option>
  63.                 </select>
  64.             </div>
  65.             <div id="table">
  66.             </div>
  67.         </div>
  68.     </div>
  69. </div>
  70. </div>
  71. </body>
  72. </html>
  73.  
  74. <script type="text/javascript">
  75.  
  76. $(document).ready(function(){
  77.     $("option").load('tables.php');
  78. })
  79. </script>
  80.  
  81. <script type="text/javascript">
  82. $(document).ready( function() {
  83.     $("#options").change(function() {
  84.     $("#table").load('mysql.php?id=' + $(this).val());
  85. }); })
  86. </script>
  87.  
  88. <script>
  89. $(document).ready(function(){
  90.     $.getJSON("tables.php", function (data){
  91.         var jsonData
  92.         $.each(data, function(i, menuItems){
  93.             jsonData = '<select>' + jsonData + '</select>';
  94.             $(jsonData).appendTo('#options');
  95.             alert(1);
  96.         })
  97.     })
  98. })
  99.  
  100.  
  101.  
  102. </script>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top