title: Get table names and print first row of each
body: <p>How do I print the first row of each table?</p>
  
  <pre><code>&lt;?php
  $dbname = 'mysql_database';
  
  if (!mysql_connect('mysql_host', 'mysql_user', 'mysql_password')) {
  echo 'Could not connect to mysql';
  exit;
  }
  
  mysql_select_db($dbname);
  
  $sql = "SHOW TABLES FROM $dbname";
  $result = mysql_query($sql);
  
  if (!$result) {
  echo "DB Error, could not list tables\n";
  echo 'MySQL Error: ' . mysql_error();
  exit;
  }
  
  while ($row = mysql_fetch_row($result)) {
  //echo "&lt;br&gt;Table name is: {$row[0]}\n";
  
  // Make a MySQL Connection
  $tableQuery = "SELECT * FROM $dbname.$row[0] LIMIT 1";  
  $tableResult = mysql_query($tableQuery) or die(mysql_error());
  
  $firstRow = mysql_fetch_array($tableResult) or die(mysql_error());
  //echo $firstRow['name']. " - ". $firstRow['age']."&lt;br&gt;";
      //how do i print field name row and first row of values 
      //if I don't know the field names
  
  
  }
  
  //mysql_free_result($result);
  ?&gt;
  </code></pre>