Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //connect to the db
- $host = 'localhost';
- $user = 'root';
- $pass = '';
- $db = 'testdb';
- $connection = mysqli_connect($host, $user, $pass, $db) or die("cannot connect to db");
- //show tables
- $result = mysqli_query($connection, 'SHOW TABLES') or die ('cannot show tables');
- while($tableName = mysqli_fetch_row($result))
- {
- $table = $tableName[0];
- echo '<h3>' ,$table, '</h3>';
- $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