Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $host = '';
- $user = '';
- $pass = '';
- $db = '';
- ?>
- <style type="text/css">table {border-collapse:collapse; border: none} td, th {border:1px solid #CCC; padding:5px}</style><?php $con = mysql_connect($host, $user, $pass) or die(mysql_error()); mysql_select_db($db, $con) or die(mysql_error()); $tables = mysql_query("SHOW TABLES") or die(mysql_error()); while ($row = mysql_fetch_assoc($tables)) { foreach($row as $value) { $aTables[] = $value; } } $i = 0; foreach ($aTables as $table) { $desc = mysql_query("describe " . $table); while ($row = mysql_fetch_assoc($desc)) { $aFields[$i][] = $row["Field"]; } $i++; } for ($i = 0; $i < count($aTables); $i++) { ?><h2><?php echo $aTables[$i]; ?></h2><table><?php $result = mysql_query("SELECT * FROM " . $aTables[$i]) or die(mysql_error()); echo "<tr>"; foreach ($aFields[$i] as $field) { echo "<th>" . $field . "</th>"; } echo "</tr>"; while ($row = mysql_fetch_assoc($result)) { echo "<tr>"; foreach ($aFields[$i] as $field) { echo "<td>" . $row[$field] . "</td>"; } echo "</tr>"; } ?></table><?php } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement