Guest User

Vis alt

a guest
Dec 15th, 2013
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.68 KB | None | 0 0
  1. <?php
  2.  
  3. $db = new mysqli('localhost', 'ej', '1234', 'navnet_paa_databasen');
  4. $tables = array();
  5.  
  6. $rs = $db->query("SHOW TABLES");
  7. while ($row = $rs->fetch_row())
  8.     $tables[] = $row[0];
  9.  
  10. foreach ($tables as $table) {
  11.     echo '<h1>Data fra ' . $table . '</h1>';
  12.     echo '<table style="width: 100%;"><thead>';
  13.     echo '<tr>';
  14.    
  15.     $cols = array();
  16.    
  17.     $rs = $db->query("SHOW COLUMNS FROM $table");
  18.     while ($row = $rs->fetch_row()) {
  19.         echo '<td>', $row[0] ,'</td>';
  20.     }
  21.    
  22.     echo '</thead></tr>';
  23.    
  24.     $rs = $db->query("SELECT * FROM $table");
  25.     while ($row = $rs->fetch_assoc()) {
  26.         echo '<tr>';
  27.        
  28.         foreach ($row as $field)
  29.             echo '<td>', $field ,'</td>';
  30.        
  31.         echo '</tr>';
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment