Pass multiple variables from controller to view in codeigniter
<p>How to pass multiple variables from controller to view in codeigniter?</p>

<p>This is my controller:</p>

<pre><code>function viewmembers(){
            $this-&gt;load-&gt;model('UsersModel');
            $data['students'] = $this-&gt;UsersModel-&gt;studentlist_all();
            $data['user'] = $this-&gt;UsersModel-&gt;select_admin($id);
            $this-&gt;load-&gt;view('portal/viewstudents', $data);
    }
</code></pre>

<p>And here is my view:</p>

<pre><code>    foreach($user as $user_select){
                            $id = $user_select['USERNAME']; 
                            $fname = $user_select['FNAME'];
                            $mname = $user_select['MNAME'];
                            $lname = $user_select['LNAME'];
                            $nick = $user_select['NICK'];
                            }
    echo $nick;
</code></pre>

<p>It gives me "undefined variable: nick".</p>

<p>I also tried
print_r($user), but it gives me a value "Array()" </p>

<p>althought print_r($students) works</p>