Deanznet Posted August 11, 2009 Share Posted August 11, 2009 Help list the Mysql Tables in a drop down box? Select Category <? $sql = "SHOW TABLES FROM $db_name"; $result = mysql_query($sql); if (!$result) { echo "DB Error, could not list tables\n"; echo 'MySQL Error: ' . mysql_error(); exit; } while ($row= mysql_fetch_row($result)) { echo "<select name=Field>"; echo "<option value={$row[0]}>"; echo "<option value={$row[0]}>"; echo mysql_table_name($result, $i); } echo "</select></form>"; ?> I know the code is really messed up.. Can someone help. Link to comment https://forums.phpfreaks.com/topic/169823-listing-tables-in-a-drop-down-box/ Share on other sites More sharing options...
MatthewJ Posted August 11, 2009 Share Posted August 11, 2009 <?php $sql = "SHOW TABLES FROM $db_name"; $result = mysql_query($sql); if (!$result) { echo "DB Error, could not list tables\n"; echo 'MySQL Error: ' . mysql_error(); exit; } echo "<select name=Field>"; while ($row= mysql_fetch_row($result)) { echo "<option value={$row[0]}>{$row[0]}</option>"; } echo "</select>"; ?> Link to comment https://forums.phpfreaks.com/topic/169823-listing-tables-in-a-drop-down-box/#findComment-895926 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.