Advertisement
imoda

Get All Info From Unknown MySQL Database

Jul 29th, 2011
1,479
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.04 KB | None | 0 0
  1. <?php
  2.     $host = '';
  3.     $user = '';
  4.     $pass = '';
  5.     $db   = '';
  6. ?>
  7. <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