---------------------------------------------------
| Date: 2003-02-17 00:17:38 |
| Filename: listtables.php |
| Author: detour@metalshell.com |
| |
| http://www.metalshell.com/ |
---------------------------------------------------
Tables in $dbname");
echo('');
// Make connection to mysql
$dbid = @mysql_connect($dbhost, $dbuser, $dbpass);
// Retrieve tables list from the database.
// A normal result set is stored $dbtables.
$dbtables = mysql_list_tables($dbname, $dbid);
// mysql_num_rows is used to get the number of rows in a result set,
$dbtable_num = mysql_num_rows($dbtables);
// Cycle through each table
for($x=0; $x < $dbtable_num; $x++) {
// The table indexed at $x
$current_table = mysql_tablename($dbtables, $x);
echo("$current_table
");
// Get all fields from the table $current_table
$dbfields = mysql_list_fields($dbname, $current_table, $dbid);
$dbfield_num = mysql_num_fields($dbfields);
// Break apart the field to print it.
for($y=0; $y < $dbfield_num; $y++) {
$field_name = mysql_field_name($dbfields, $y);
$field_type = mysql_field_type($dbfields, $y);
$field_len = mysql_field_len($dbfields, $y);
$field_flag = mysql_field_flags($dbfields, $y);
echo("$field_name ( $field_type of size $field_len ) ");
echo(" FLAGS: $field_flag
");
}
}
// Close the database connection.
mysql_close($dbid);
echo('