MySQL Database Structure and Data Lister

Started by
1 comment, last by Thoover 10 years, 9 months ago

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

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!?

Given enough eyeballs, all mysteries are shallow.

MeAndVR

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

Thanks for the help

BASICFreak

This topic is closed to new replies.

Advertisement