• Advertisement
Sign in to follow this  

MySQL Database Structure and Data Lister

This topic is 1657 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

First here is the code:

<?php
require './includes/config.ini.php';
?>
<html>
    <head>
        <title>Database Structure</title>
    </head>
    <body bgcolor="#FFFFFF" text="#000000">
        <center><h1><?PHP echo $database; ?></h1>
            <table border="1" cellspacing="0" width="820">
                <tr>
                    <td width="175">Table</td>
                    <td width="175">Field</td>
                    <td width="175">Field Type</td>
                    <td width="290">Value</td>
                </tr>
        
<?PHP
mysql_connect($server, $username, $password) or die(mysql_error());
mysql_select_db($database) or die(mysql_error());


$tableresults = mysql_query("SHOW TABLES");
while ( $tablerows = mysql_fetch_array($tableresults) )
{
    $structureresults = mysql_query("DESCRIBE ".$tablerows[0]);
    while ( $structurerows = mysql_fetch_array($structureresults) )
    {
        $result = mysql_query("SELECT * FROM ".$tablerows[0]);
        while ( $row = mysql_fetch_array($result) )
        {
            echo '<tr>
                    <td>'.$tablerows[0].'</td>
                    <td>'.$structurerows['Field'].'</td>
                    <td>'.$structurerows['Type'].'</td>
                    <td>'.$row[$tablerows['Field']].'</td>
                </tr>';
        }
    }
}
?>
            </table>
        </center>
    </body>
</html>

The issue I am having is I am not displaying any of the values from the table, all other information is displaying fine, anyone have any ideas.

 

Could it be that I cannot use a variable to locate an array point?

 

 

Any help is greatly appreciated

 

BASICFreak

 

Share this post


Link to post
Share on other sites
Advertisement

 

First here is the code:

...
            echo '<tr>
                    <td>'.$tablerows[0].'</td>
                    <td>'.$structurerows['Field'].'</td>
                    <td>'.$structurerows['Type'].'</td>
                    <td>'.$row[$tablerows['Field']].'</td>
                </tr>';
...

The issue I am having is I am not displaying any of the values from the table, all other information is displaying fine, anyone have any ideas.

 

Could it be that I cannot use a variable to locate an array point?

 

 

Any help is greatly appreciated

 

BASICFreak

 

 

Shouldn't it be:

<td>'.$row[$structurerows['Field']].'</td>

?

 

$tablerows just holds the Table names if I understand the code correctly!?

Edited by DareDeveloper

Share this post


Link to post
Share on other sites

wow I can't believe I missed that for this long...

 

Thanks for the help

BASICFreak

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement