i have been given access to a database but i do not know any of the tables or fields inside the tables.

Is there a simple way i can list this contents?

<?
$host = "localhost";
$user = "kmw";
$pass = "qwerty";
$db = "HGARPS";
?>

    [man]mysql_list_tables[/man], [man]mysql_list_fields[/man]

      cheers that put me in the right direction....
      got this back. not really sure how to pull out just the row names instead of all the details....

      Table: pictures
      Array ( [Field] => synchDel [Type] => smallint(6) [Null] => [Key] => [Default] => 0 [Extra] => ) Array ( [Field] => synchRec [Type] => datetime [Null] => YES [Key] => MUL [Default] => [Extra] => ) Array ( [Field] => ipcode [Type] => char(9) [Null] => [Key] => MUL [Default] => [Extra] => ) Array ( [Field] => ipicfile [Type] => char(16) [Null] => [Key] => PRI [Default] => [Extra] => ) Array ( [Field] => itype [Type] => char(2) [Null] => [Key] => [Default] => [Extra] => ) Array ( [Field] => ipicname [Type] => char(20) [Null] => [Key] => [Default] => [Extra] => ) Array ( [Field] => iregister [Type] => datetime [Null] => [Key] => MUL [Default] => 0000-00-00 00:00:00 [Extra] => ) Array ( [Field] => iamend [Type] => datetime [Null] => [Key] => MUL [Default] => 0000-00-00 00:00:00 [Extra] => ) Array ( [Field] => ipicsent [Type] => tinyint(1) [Null] => [Key] => [Default] => 0 [Extra] => )

        Just loop through the array and echo the field value.

        foreach($array as $sub) {
           echo $sub['Field'].'<br />';
        }

          have done this. but something is a bit wrong. it only seems to be printing one letter for each sub?

          http://pod-185.dolphin-server.co.uk/Reapit/hgasite/hg_php/hg_start_b.php

          if (!$result) {
          echo "DB Error, could not list tables\n";
          echo 'MySQL Error: ' . mysql_error();
          exit;
          }

          while ($row = mysql_fetch_row($result)) {
          echo "<BR><b>Table: $row[0]</b><BR>";
          $resultx = mysql_query("SHOW COLUMNS FROM $row[0]");
          if(!$resultx) {
          echo 'Could not run query: ' . mysql_error();
          exit;
          }
          if (mysql_num_rows($resultx) > 0) {
          while ($rowx = mysql_fetch_assoc($resultx)) {
          // print_r($rowx);
          foreach($rowx as $sub) {
          echo $sub['Field'];
          }
          }
          }

            Write a Reply...