Bladephp: Now with 8+ codeigniter, php, and laravel project 8+ php project From $37/Month From Rs. 2499/Month

How to Condition DropDown Codeigniter

by
Category:codeigniter
codeigniter mysql
How to Condition DropDown Codeigniter

We will demonstrate you to create condition a form containing a select option box field using CodeIgniter PHP framework.

In our example, we have created a select option field in form with fetched values from database using for each loop and set condition rules for fields.

<select name="outlet" class="form-control">
    <option value="">Select Outlet</option>
    <?php
    foreach ($getOutlet as $outlet)
    {
        $selected = '';
        if(!empty($this->input->get('outlet')))
        {
            if($outlet->id == $this->input->get('outlet'))
            {
                $selected = 'selected';
            }
        }
    ?>
    <option <?=$selected?> value="<?=$outlet->id?>"><?=$outlet->name?></option>
    <?php
    }
    ?>
</select>

0 Comments


Html code work in comment box


Related Post