简体   繁体   中英

How to edit codeigniter form drop down

I am using codeigniter form drop down.

add_store.php code is like this :-

 <tr>
            <td>country</td>
            <td><?=form_input('country', set_value('country'));?></td>
            <td class="error"><?php echo form_error('country'); ?></td>
        </tr>
    <tr>
        <td><?=form_dropdown('Equipment',$options = array(
                                '1'   => '1',
                                '2'   => '2',
                                '3'   => '3',
                                '4'   => '4',
                                '5'   => '5',
                                '6'   => '6',
                                '7'   => '7',
                                '8'   => '8',
                                '9'   => '9',
                                '10' => '10'));?></td>
    </tr>

I added this form in to the database and it works fine.

Now I want to edit this page. I am doing something like this :-

edit_store.php page is here

<tr>
                <td>country</td>
                <td><?=form_input('country', set_value('country', $store['country']));?></td>
                <td class="error"><?php echo form_error('country'); ?></td>
</tr>

 <tr>
                <td>Equipment Rating</td>
                <td><?=
                                $selected_Equipment = $this->input->post('Equipment');
                                form_dropdown('Equipment'$selected_Equipment);?></td>
    // what i can do here, I am doing something wrong here??????????????????????????????????????????            
</tr>

My Question is: what can I do for selected Drop down coming from database ?

How to edit Drop down selected value?

So what can I do ???

    <?php
    $selected_Equipment = '1';
    $options = array(
                     '1'   => '1',
                     '2'   => '2',
                     '3'   => '3',
                     '4'   => '4',
                     '5'   => '5',
                     '6'   => '6',
                     '7'   => '7',
                     '8'   => '8',
                     '9'   => '9',
                     '10' => '10');
   form_dropdown('Equipment',$options,$selected_Equipment);
   ?>

Hope this helps!

Kugutsumen is right, your syntax for the form_dropdown function is a bit wrong. You can look at it here and see the arguments it takes: http://codeigniter.com/user_guide/helpers/form_helper.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM