# Dynamic select field php

**URL:** <https://forum.kirupa.com/t/dynamic-select-field-php/203355>\
**Category:** programming\
**Created:** [October 10, 2006, 12:53pm UTC](https://forum.kirupa.com/t/dynamic-select-field-php/203355 "2006-10-10T12:53:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pucca](https://avatars.discourse-cdn.com/v4/letter/p/5f8ce5/32.png) [@pucca](https://forum.kirupa.com/u/pucca)\
**Post date:** [October 10, 2006, 12:53pm UTC](https://forum.kirupa.com/t/dynamic-select-field-php/203355/1 "2006-10-10T12:53:36Z")

</div>

Hi there

I’m putting a form in a database driven website. At the select field, I would like to retrieve the information from the database as a drop down menu.

Here’s my code : - which I put inside the form :

```php
   
              $query = 'SELECT `Name` FROM desta_services';
                        $result = mysql_query ($query)
                        or die ('Query failed');
                        echo '<select name="category">';
                        while ($row = mysql_fetch_array ($result)) {
                        echo '<option>'$row['Name']'</option>';
                        }
                        echo '</select>';          

                  

```

It doesn’t work??? Can anyone tell me what the prob is?

Thanks!
