PHP Option Dropdown set Option to One Stored in DB

前端 未结 2 1571
忘了有多久
忘了有多久 2021-01-26 11:42

I have a PHP form which I use to edit a record in the MySQL data base and it has a drop down list of values I would like to set the option that is held in the database to be the

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-26 12:05

    If it's a small dropdown this is quick and easy

    
                    type_id))
                            $tid = $item->type_id;
                        else
                            $tid = 1; // Set this to your preferred default
                    ?>
                    
    

    If it's a bigger dropdown write a php function to create the dropdown using an iterative approach

    EDIT * is this right as it is now defaulting to the $tid

                                      
                                
    

提交回复
热议问题