Query for Tables
Moderator: General Moderators
Query for Tables
I am wanting to get a dynamic list of TABLES in a Database. Is this possible? How would it look if it is possible?
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Code: Select all
SHOW TABLESFair enough. I'm trying to get the list of the tables into a multiple select form field:
Here is my query and connection code: I put **** on db name, disregard them.
I guess my question is, how would I echo the results?
Code: Select all
<select name="tablesї]" size="6" multiple="multiple" class="forms" id="tablesї]">
<option value="con_news">var_month</option>
<?php
do {
?>
<option value="<?php echo $row_tableLISTї'id']?>"><?php echo $row_tableLISTї'id']?></option>
<?php
} while ($row_tableLIST = mysql_fetch_assoc($tableLIST));
$rows = mysql_num_rows($tableLIST);
if($rows > 0) {
mysql_data_seek($tableLIST, 0);
$row_tableLIST = mysql_fetch_assoc($tableLIST);
}
?>Code: Select all
<?php mysql_select_db($*****, $*******);
$query_tableLIST = "SHOW TABLES";
$tableLIST = mysql_query($query_tableLIST, $*****) or die(mysql_error());
$row_tableLIST = mysql_fetch_assoc($tableLIST);
$totalRows_tableLIST = mysql_num_rows($tableLIST);
?>I guess my question is, how would I echo the results?
I got it. Thanks for the help. I was confused because I thought that there should have been an echo field name. But that cleared it up. Thanks for the help again.
Here is the code for you readers:
QUERY CODE:
ECHO RESULTS CODE:
Here is the code for you readers:
QUERY CODE:
Code: Select all
<?php
mysql_select_db($databasename, $connect);
$query_queryLIST = "SHOW TABLES";
$queryLIST = mysql_query($query_queryLIST, $connect) or die(mysql_error());
$row_queryLIST = mysql_fetch_row($queryLIST);
$totalRows_queryLIST = mysql_num_rows($queryLIST);
mysql_free_result($queryLIST);
?>Code: Select all
<?php
<?php
do {
?>
<option value="<?php echo $row_queryLIST[0]; ?>"><?php echo $row_queryLIST[0]; ?></option>
<?php
} while ($row_queryLIST = mysql_fetch_row($queryLIST));
$rows = mysql_num_rows($queryLIST);
if($rows > 0) {
mysql_data_seek($queryLIST, 0);
$row_queryLIST = mysql_fetch_row($queryLIST);
}
?>