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 Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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. 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.