payney Posted October 25, 2007 Share Posted October 25, 2007 Hello guys, long time no Q! Anyway, I am wanting a dynamic select list which is populated from my DB. My query is: $query = "SELECT pk, type FROM un_styles"; I want to display the type in the select list, then use the selected type. So what i am basically asking is could someone show me the code to do this please. Thanks Sam Quote Link to comment https://forums.phpfreaks.com/topic/74758-dynamic-select-list/ Share on other sites More sharing options...
GingerRobot Posted October 25, 2007 Share Posted October 25, 2007 It'll be something like: <?php $query = "SELECT pk, type FROM un_styles"; $result = mysql_query($query) or die(mysql_error()); echo '<select name="type">'; while($row = mysql_fetch_assoc($result)){ echo '<option value="'.$row['type'].'">'.$row['type'].'</option>'; } echo '</select>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/74758-dynamic-select-list/#findComment-377910 Share on other sites More sharing options...
payney Posted October 25, 2007 Author Share Posted October 25, 2007 nice one ginger! Quote Link to comment https://forums.phpfreaks.com/topic/74758-dynamic-select-list/#findComment-377916 Share on other sites More sharing options...
MadTechie Posted October 25, 2007 Share Posted October 25, 2007 also here http://www.phpfreaks.com/forums/index.php/topic,155984.0.html Quote Link to comment https://forums.phpfreaks.com/topic/74758-dynamic-select-list/#findComment-377954 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.