tony007
Oct 17th, 2007, 05:38 AM
hi all. Could any one show me how to display table names of a specific database using php? I tried the following but didn't output any thing!!
<?php
$server = "localhost"; // MySQL hostname
$username = "root"; // MySQL username
$password = "?????"; // MySQL password
$dbname = "kingkong"; // MySQL db name
$db = mysql_connect($server, $username, $password) or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());
$sql = "SHOW TABLES FROM kingkong ";
$fp = fopen("query.txt", "w");
fwrite($fp, $sql);
fclose($fp);
$result = mysql_query( $sql );
while($row = @mysql_fetch_array($result)) {
?>
<?php echo $row["tables"] ?>
<?
}
?>
<?php
$server = "localhost"; // MySQL hostname
$username = "root"; // MySQL username
$password = "?????"; // MySQL password
$dbname = "kingkong"; // MySQL db name
$db = mysql_connect($server, $username, $password) or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());
$sql = "SHOW TABLES FROM kingkong ";
$fp = fopen("query.txt", "w");
fwrite($fp, $sql);
fclose($fp);
$result = mysql_query( $sql );
while($row = @mysql_fetch_array($result)) {
?>
<?php echo $row["tables"] ?>
<?
}
?>