[SOLVED] controller not passing Data to my veiw

Ok so the second installment of Neo needs help and feels like a tard is as follows.

My controller is not passing data to my my veiw, or im not reading the error im getting correctly as its been many years since ive worked with php, somewhere around php 3 Tongue.

Here is my controller
class Banned_user extends Controller{
    private $data;
    function Banned_user(){
    function index(){
        $data['query'] = $this->bu->get_entries();
        //$data['title'] = 'Banned Users';
       // $data['page'] = 'banned_users';    
        $this->load->view('banned_users', $data);    

here is the foreach loop in my veiw
<?php foreach($query as $row):?>

<li>&lt;?php echo $banned_user_slname;?&gt;</li>
<hr />

&lt;?php endforeach;?&gt;

and lastly here is there error
Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined variable: banned_user_slname

Filename: views/banned_users.php

Line Number: 6

thanks in advance.

[eluser]Italo Domingues[/eluser]
Read the documentation for CI and search the forum, that kind of questions surely must have some topic

Change your code

&lt;?php foreach($query as $row):?&gt;

<li>&lt;?php echo $banned_user_slname;?&gt;</li>
<hr />

&lt;?php endforeach;?&gt;


&lt;?php foreach($query as $row):?&gt;

<li>&lt;?php echo $row['name']; ?&gt;</li>
<hr />

&lt;?php endforeach;?&gt;

Hey!!! i feel u r doing some thing wrong in u'r view file in that foreach loop. It should be like this...

foreach($query as $item):
$headlineId = $item->headline_id ; // "headline_id" is one of the field which has accessed from DB table
echo $headlineId;

Hope u've got the idea...

thanks mi6crazyheart, that worked great, i was following along the CI video tutorial and the way i had it was the way they were doing it, also i looked at the user manual and thats the way they had it as well, so I was at a complete loss, ive been looking on the forums and google for the better part of an hour or more before I posted here on this.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.