Version: 1.01
Type: Full Script
Category: Databases
License: GNU General Public License
Description: Choose you database and then your table. This scripts provides you with information about the fields in your tables.
<!-- There are three sections of this file each one needs to be its own page with the names as they are stated -->
<!-- datainfo.php -->
<html>
<head>
<title>PHP Database Info</title>
</head>
<body>
<font size="2" face="Verdana"><strong>PHP SQL Database Info</strong></font>
<?php
$host = "localhost";
$user = "root";
$password = "";
?>
<form action="table.php" method="post">
Please select a database:<br><br>
<select name="database" size="1">
<?php
mysql_connect($host, $user, $password);
$db_table = mysql_list_dbs();
for($i = 0; $i < mysql_num_rows($db_table); $i++){
echo("<option>" . mysql_tablename($db_table, $i));
}
?>
</select>
<br><br>
<input type="Submit" value="Choose Database">
</form>
</body>
</html>
<!-- table.php -->
<html>
<head>
<title>PHP Database Info</title>
</head>
<body>
<font size="2" face="Verdana"><strong>PHP SQL Database Info</strong></font>
<?php
$host = "localhost";
$user = "root";
$password = "";
?>
<form action="tableinfo.php" method="post">
<?php echo "Please select the table from the database <b>" . $_POST['database'] . "</b>:"; ?><br><br>
<select name="table" size="1">
<?php
mysql_connect($host, $user, $password);
$db_table = mysql_list_tables($_POST['database']);
for($i = 0; $i < mysql_num_rows($db_table); $i++){
echo("<option>" . mysql_tablename($db_table, $i));
}
?>
</select>
<br><br>
<input name="database2" type="hidden" value="<?php echo $_POST['database']; ?>">
<input type="Submit" value="Choose Table">
</form>
</body>
</html>
<!-- tableinfo.php -->
<html>
<head>
<title>PHP Database Info</title>
</head>
<body>
<font size="2" face="Verdana"><strong>PHP SQL Database Info<br></strong></font>
<?php
$host = "localhost";
$user = "root";
$password = "";
?>
<?php echo "Information about the table <b>" . $_POST['table'] . "</b> in the database <b>" . $_POST['database2'] . "</b>:"; ?><br><br>
<table>
<?php
mysql_connect($host, $user, $password);
$fields = mysql_list_fields($_POST['database2'], $_POST['table']);
$columns = mysql_num_fields($fields);
for ($i = 0; $i < $columns; $i++) {
echo "<font size=\"1\" face=\"Verdana\"><b>" . mysql_field_name($fields, $i) . "</b> - " . mysql_field_type($fields, $i) . ", " . mysql_field_flags($fields, $i) . "<br>";
}
?>
</table>
</body>
</html>