如何从数据库中检索所有表名?

I'm trying to retrieve all table names from a MySQL database and link them to a dropdown list. Then I want to store those table names in a table and preview them.

here's my code...

<?php 
$sql = "SHOW TABLES FROM $ip";
$result = mysql_query($sql);
?>
<form id="form1" name="form1" method="post" action="newloay.php">
<select name="select" id="select" required>
    <?php
     while($row =  mysql_fetch_array($result)){
    ?>
        <option> <?php print $row[0] ?> </option>
    <?php 
     }  ?>

    }
</select>

Follow the following code to get the Name of the Tables in your Database :

<?php
$dbname = 'mysql_dbname';

if (!mysql_connect('mysql_host', 'mysql_user', 'mysql_password')) {
    echo 'Could not connect to mysql';
    exit;
}

$sql = "SHOW TABLES FROM $dbname";
$result = mysql_query($sql);

if (!$result) {
    echo "DB Error, could not list tables
";
    echo 'MySQL Error: ' . mysql_error();
    exit;
}

while ($row = mysql_fetch_row($result)) {
    echo "Table: {$row[0]}
";
}

mysql_free_result($result);
?>

Hope this helps, for more details on this, please check out THIS PAGE

MySQL :

SELECT 
  table_name
FROM 
  my_schema.tables

Where my_schema is your schema name , $ip, I guess.