etymole Posted April 15, 2010 Share Posted April 15, 2010 Hi As the title suggests my problem is that I'm trying to get some of the enumerated fields (e.g. Sex, Age range, etc) to link into my drop down boxes in my script. I also want to be able to update the specific selection for each record with the drop down box. I have managed to get this populate and update idea working using text form fields but I'm having a real issue trying to figure out how to get it working for a drop down menus and combo boxes. I'm assuming a while loop, looping through the options available and creating a new <option> each time. I have seen code snippets that do this which I've been trying to use, but these snippets refer to an entire table, I just want to select the enum options from a specific column. Below is the snippet I think I could use if only I could get the query correct. <form method="get" action="view_urls.php"> <select name="type"> <option value="NULL">Choose a Category:</option> '; // Retrieve and display the available categories. $query = 'SELECT * FROM url_categories ORDER BY category ASC'; //POSSIBLE TO MAKE THIS QUERY SELECT ONLY THE ENUM OPTIONS???? $result = mysql_query ($query); while ($row = mysql_fetch_array ($result, MYSQL_NUM)) { echo "<option value=\"$row[0]\">$row[1]</option> "; } // Complete the form. echo '</select> <input type="submit" name="submit" value="Go!"> </form> I'm pretty new to PHP and SQL and this is a little out of my grasp right now. I appreciate all help. Link to comment https://forums.phpfreaks.com/topic/198623-populating-a-drop-down-menu-with-enum-data-from-sql-table/ Share on other sites More sharing options...
AdRock Posted April 15, 2010 Share Posted April 15, 2010 Not tried but i found this http://akinas.com/pages/en/blog/mysql_enum/ Link to comment https://forums.phpfreaks.com/topic/198623-populating-a-drop-down-menu-with-enum-data-from-sql-table/#findComment-1042305 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.