Jump to content

Dynamic Select list


payney

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/74758-dynamic-select-list/
Share on other sites

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>';
?>

Link to comment
https://forums.phpfreaks.com/topic/74758-dynamic-select-list/#findComment-377910
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.