Jump to content

  • Log In with Google      Sign In   
  • Create Account

MySQL Database Structure and Data Lister


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 BASICFreak   Members   -  Reputation: 115

Like
0Likes
Like

Posted 06 July 2013 - 02:35 AM

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

 



Sponsor:

#2 DareDeveloper   GDNet+   -  Reputation: 975

Like
2Likes
Like

Posted 06 July 2013 - 03:09 AM

 

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, 06 July 2013 - 03:12 AM.

Given enough eyeballs, all mysteries are shallow.

ProcGames.com


#3 BASICFreak   Members   -  Reputation: 115

Like
0Likes
Like

Posted 06 July 2013 - 03:26 AM

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

 

Thanks for the help

BASICFreak






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS