 <?php

$host = 'localhost';
$user = 'dheacock_eticstub';
$pass = 'dbkv20yz';
$db   = 'dheacock_stubhub';
    
// Connecto to the MySQL server
$link = mysql_connect($host,$user,$pass);
if ($link){
      // Select the database
    mysql_selectdb($db,$link);
        
    // Write xml header information
    echo htmlspecialchars(
      '<DBSchema db="'.$db.'" host="'.$host.'" user="'.$user.'" pass="'.$pass.'">');
    echo "<br/>";
           
    // Get all tables
    $result = mysql_query('SHOW TABLES');
    while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
        // Get table name
        $table = $row[0]  ;
        
        // Get table info        
        $struct = mysql_query('DESCRIBE '.$table);

        // Write table info       
        echo "&nbsp;&nbsp;&nbsp;"
             .htmlspecialchars('<Table name="'.$table.'">')."<br/>";

        // Get table description       
        while ($row2 = mysql_fetch_array($struct, MYSQL_NUM)) {
            $autoi = (strstr($row2[5],'auto_increment')) ? 'true' : 'false';
            echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
            echo htmlspecialchars('<Field name="'.$row2[0].'" ');
            echo htmlspecialchars('type="'.$row2[1].'" ');
            echo htmlspecialchars('null="'.$row2[2].'" ');
            echo htmlspecialchars('key="'.$row2[3].'" ');
            echo htmlspecialchars('default="'.$row2[4].'" ');
            echo htmlspecialchars('autoincrement="'.$autoi.'"/>')."<br/>";
        }

        // Write table section close element       
        echo "&nbsp;&nbsp;&nbsp;"
            .htmlspecialchars('</Table>')."<br/>";
                
    }
    
    // Write the final close element
    echo htmlspecialchars('</DBSchema>')."<br/>";
}
  
?> 
