note 18067 deleted from function.mysql-tablename by didou
| From: | didou@php.net | Date: | Sat, 16 Aug 2003 09:17:15 +0000 |
| Subject: | note 18067 deleted from function.mysql-tablename by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-54295@lists.php.net to get a copy of this message | ||
Note Submitter: mmaniscalco18@yahoo.com
----
This code is for a pull down list of the tables in your Database. Works well with forms.
<?PHP
$DBhost = "localhost";
$DBname = "mysql";
// Connecting, selecting database.
$link = mysql_connect("$DBhost");
mysql_select_db("$DBname");
echo "<select name=\"table\">";
$result = mysql_list_tables($DBname);
for ($i = 0; $i < mysql_num_rows($result); $i++) {
$tbl_names[$i] = mysql_tablename($result, $i);
echo "<option
value=\"".$tbl_names[$i]."\">".$tbl_names[$i]."</option>\n";
}
echo "</select>\n";
// Closing connection.
mysql_close($link);
?>