note 18067 modified in function.mysql-tablename by didou

From: Date: Sat, 17 May 2003 21:38:14 +0000
Subject: note 18067 modified in function.mysql-tablename by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-48283@lists.php.net to get a copy of this message
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); ?> --was-- 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); ?> http://www.php.net/manual/en/function.mysql-tablename.php

« previous php.notes (#48283) next »