Welcome Guest, Not a member yet? Register   Sign In
passing data to a view...
#1

[eluser]Unknown[/eluser]
I've read the user manual about passing data to a view, and understand about passing arrays, but have a question about just sending a single variable. I admit that I'm just learning CI, so this may be pretty elementary...

In my controller I have

Code:
$login_error['error'] = ('<p class="error"> This login is incorrect </p>');
            $this->load->view('login_form', $login_error);
            return;

And in my view
Code:
<p class="heading">User Login</p>

    &lt;?php echo ($error); ?&gt;

This works and all.. but just to wrap my head around it, what if I just wanted to send $error as in:

Code:
$error = ('<p class="error"> This login is incorrect </p>');
            $this->load->view('login_form', $error);
            return;

How would I reference that in my view? I've tried just $error, but it gives me an undefined variable error. Is data passed to the view always an array? I think thats what the user guide is trying to say, but I wanted to be sure.

Thanks...


Messages In This Thread
passing data to a view... - by El Forum - 09-11-2010, 12:06 PM
passing data to a view... - by El Forum - 09-11-2010, 01:08 PM
passing data to a view... - by El Forum - 09-11-2010, 02:49 PM



Theme © iAndrew 2016 - Forum software by © MyBB