reecec Posted July 29, 2006 Share Posted July 29, 2006 hi please can someone help me I need a script that will get the table fields and put them in a drop down would this be done using DESCRIBE thanks reece Link to comment https://forums.phpfreaks.com/topic/15976-table-fields-in-a-dropdown/ Share on other sites More sharing options...
pixy Posted July 29, 2006 Share Posted July 29, 2006 Here's basically how you'd do it:<?php// Connect to database$query = "SELECT id, name FROM fields";$result = mysql_query($query);echo '<select name="fields">';while ($row = mysql_fetch_array($result, MYSQL_NUM)) { echo '<option value="'.$row[0].'">'.$row[1].'</option>';}echo '</select>';?>Of course, replace the values you're working with to make it work. Link to comment https://forums.phpfreaks.com/topic/15976-table-fields-in-a-dropdown/#findComment-65638 Share on other sites More sharing options...
reecec Posted July 30, 2006 Author Share Posted July 30, 2006 thanks for your reply sorry i may not have explained it well i mean the column names not the row valuesthanks reece Link to comment https://forums.phpfreaks.com/topic/15976-table-fields-in-a-dropdown/#findComment-65655 Share on other sites More sharing options...
pixy Posted July 30, 2006 Share Posted July 30, 2006 The column names? I dont know if you can do that...you have to select things BASED on the column names. Link to comment https://forums.phpfreaks.com/topic/15976-table-fields-in-a-dropdown/#findComment-65656 Share on other sites More sharing options...
AndyB Posted July 30, 2006 Share Posted July 30, 2006 [b]describe[/b] provides ALL the information - http://www.webdevelopersnotes.com/tutorials/sql/mysql_lesson_mysql_tables.php3get the column (field) names [b]only[/b] - see the snippet by jamesl at si-usa dot com at http://ca.php.net/manual/en/function.mysql-field-name.phpYou should be able to do what you want based on that snippet and a little coding. Link to comment https://forums.phpfreaks.com/topic/15976-table-fields-in-a-dropdown/#findComment-65661 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.