MySQL Show mySQL database tables

Show mySQL database tables

<head>
<title>Show mySQL database tables</title>
</head>
<?php 
// Simple testscript which reads a mySQL database table and outputs a HTML table.
// v0.10 13-Aug-2002, by G. Knauf <efash@gmx.net>
$host='localhost';
$user='root';
$pass='';
$dbase='webauth';
$table='user_pwd';
// Connecting to MySQL database
$conn = mysql_connect($host, $user, $pass) or die("Could not connect to MySQL server $host!\n");
// To read from the database, select it
mysql_select_db($dbase) or die("Could not select database $dbase!\n");

$result = mysql_query("SELECT * FROM $table");
if (!$result) {
    echo "Error occured.\n";
    exit;
}

$num = mysql_num_rows($result); 
$nfields = mysql_num_fields($result); 

print "<h3>Table <font color=green>$table</font> contains <font color=blue>$num</font> records with <font color=blue>$nfields</font> fields:</h3>\n";
print "<table border>\n<tr>";

for ($i=0; $i < $nfields; $i++) {
  echo '<th>'.mysql_field_name($result, $i).'</th>';
}
print "</tr>\n";

for ($i=0; $i < $num; $i++) {
  echo '<tr>';
  $r = mysql_fetch_row($result);

  for ($j=0; $j < count($r); $j++) {
    echo '<td>'.$r[$j].'&nbsp;</td>';
  }

  print "</tr>\n";
}
print "</table>\n";
?>