kool_samule Posted May 24, 2010 Share Posted May 24, 2010 Hi Chaps, I'm trying to get a list of MySQL table names in a PHP/HTML Select List/Menu with the value of the Select Option being the table name. I have this as a starting point, but can't figure out how to get the values into the Select. $result = mysql_query("SHOW TABLES FROM 'DATABASE'"); while($table = mysql_fetch_array($result)) { $tables[]=$table; } Any help would be sweet. . Quote Link to comment Share on other sites More sharing options...
marcus Posted May 24, 2010 Share Posted May 24, 2010 <?php $sql = "SHOW TABLES FROM database"; $res = mysql_query($sql) or die(mysql_error()); echo '<select name="tables">'; while($row = mysql_fetch_row($res)){ echo '<option value="'.$row[0].'">'.$row[0].'</option>'; } echo '</select>'; ?> Quote Link to comment Share on other sites More sharing options...
kool_samule Posted May 24, 2010 Author Share Posted May 24, 2010 sweet, just what i'm after, i'm guessing that you could do something similar with COLUMNs as well as tables. . . . .many thanks! Quote Link to comment Share on other sites More sharing options...
marcus Posted May 24, 2010 Share Posted May 24, 2010 Yep, but instead your query would look something like $sql = "SHOW COLUMNS FROM table_name"; Quote Link to comment Share on other sites More sharing options...
kool_samule Posted May 24, 2010 Author Share Posted May 24, 2010 Got it, cheers dude Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.