Showing current value in DB in a drop down box
        Posted  
        
            by user195257
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by user195257
        
        
        
        Published on 2010-05-24T11:24:15Z
        Indexed on 
            2010/05/24
            11:31 UTC
        
        
        Read the original article
        Hit count: 279
        
Hello,
this is my code which populates a drop down menu, all working perfectly, but when editing a database record, i want the first value in the drop down to be what is currently in the database, how would i do this?
<li class="odd"><label class="field-title">Background <em>*</em>:</label> <label><select class="txtbox-middle" name="background" />
                        <?php
                        $bgResult = mysql_query("SELECT * FROM `backgrounds`");
                        while($bgRow = mysql_fetch_array($bgResult)){
                            echo '<option value="'.$bgRow['name'].'">'.$bgRow['name'].'</option>';
                        }
                        ?>
                    </select></li>
© Stack Overflow or respective owner