Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?PHP
- $host = 'localhost';
- $user = 'root';
- $pass = '';
- $db = 'testdb';
- $mysqli = new mysqli($host, $user, $pass, $db);
- //show tables
- $result = $mysqli->query("SHOW TABLES from testdb");
- //print_r($result);
- while($tableName = mysqli_fetch_row($result))
- {
- $table = $tableName[0];
- echo '<h3>' ,$table, '</h3>';
- $result2 = $mysqli->query("SHOW COLUMNS from ".$table.""); //$result2 = mysqli_query($table, 'SHOW COLUMNS FROM') or die("cannot show columns");
- if(mysqli_num_rows($result2))
- {
- echo '<table cellpadding = "0" cellspacing = "0" class "db-table">';
- echo '<tr><th>Field</th><th>Type</th><th>Null</th><th>Key</th><th>Default</th><th>Extra</th></tr>';
- while($row2 = mysqli_fetch_row($result2))
- {
- echo '<tr>';
- foreach ($row2 as $key=>$value)
- {
- echo '<td>',$value, '</td>';
- }
- echo '</tr>';
- }
- echo '</table><br />';
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement