Advertisement
Guest User

db display

a guest
Jul 28th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.85 KB | None | 0 0
  1. <?php
  2. $host = $_GET['dbhost'];
  3. $db_user = $_GET['dbuser'];
  4. $db_password = $_GET['dbpassword'];
  5. $db_name = $_GET['dbname'];
  6. $tablename = $_GET['tablename'];
  7.  
  8. error_reporting(0);
  9.  
  10. /* nazwy kolumn */
  11. $conn = new mysqli($host, $db_user, $db_password);
  12. $stmt = $conn->prepare("SELECT column_name FROM information_schema.columns WHERE table_name=?");
  13. $stmt->bind_param('s', $tablename);
  14. $stmt->execute();
  15. $stmt->bind_result($table);
  16. $stmt->store_result();
  17. echo "<tr>";
  18. while($stmt->fetch()) {
  19.     echo "<th>".$table."</th>";
  20. }
  21. echo "</tr>";
  22. $stmt->close();
  23. /* zawartość tabeli */
  24. $stmt2 = mysqli_connect($host, $db_user, $db_password, $db_name);
  25. $result = $stmt2 -> query("SELECT * FROM ".$tablename);
  26. foreach($result as $row){
  27.     echo "<tr>";
  28.         foreach($row as $field){
  29.             echo "<td>".$field."</td>";
  30.         }
  31.     echo "</tr>";
  32. }
  33. $stmt2->close();
  34. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement