How set option value selected for select tag with existing values
<p>The <code>$output</code> array return option vlaues for the select tag that I print as <code>&lt;?php print_r($store);?&gt;</code> and When I tried to update this form I need to show the <code>store</code> as selected value and also select list must have the other existing values as same as before which come from <code>$output</code>.</p>

<p>Model:</p>

<pre><code>public function getStore() {
        $this-&gt;db-&gt;select('*');
        $store = $this-&gt;db-&gt;get('tbl_store_info');
        $data = $store-&gt;result();

        $output = array();
        $output[]='&lt;option value="" disabled selected&gt;Select Store&lt;/option&gt;';
        foreach ($data as $row) {
            $output[]= '&lt;option value="' . $row-&gt;store_id . '"&gt;' . $row-&gt;store . '&lt;/option&gt;';
        }
        return $output;
    }
</code></pre>

<p>Controller:</p>

<pre><code>public function editEmployee($id='') {
        $empData=  $this-&gt;CommonModel-&gt;getEmployee_by_ID($id);
        $data['emp_list'] = $empData[0];

        $data['store']=  $this-&gt;CommonModel-&gt;getStore();
        $data['user_role']=  $this-&gt;CommonModel-&gt;getUserRole();
        $data['msg']=  $this-&gt;session-&gt;flashdata('usermsg');

        $this-&gt;load-&gt;view('common/topnav');
        $this-&gt;load-&gt;view('common/sidebar');
        $this-&gt;load-&gt;view('common/header');
        $this-&gt;load-&gt;view('common/title-header');
        $this-&gt;load-&gt;view('employee/editEmployee',$data);
        $this-&gt;load-&gt;view('common/footer');
    }
</code></pre>

<p>View:</p>

<pre><code>&lt;div class="form-group col-sm-5"&gt;
 &lt;label for="store"&gt;Store:&lt;/label&gt;
  &lt;select class="form-control" id="store" name="store" required&gt;
    &lt;option value="&lt;?php echo $emp_list-&gt;store_id; ?&gt;" selected&gt;&lt;?php echo $emp_list-&gt;store; ?&gt;&lt;/option&gt;
    &lt;?php print_r($store);?&gt;
  &lt;/select&gt;
&lt;/div&gt;
</code></pre>

<p>I just want this <code>&lt;option value="&lt;?php echo $emp_list-&gt;store_id; ?&gt;" selected&gt;&lt;?php echo $emp_list-&gt;store; ?&gt;&lt;/option&gt;</code> as selected value.</p>