Welcome Guest, Not a member yet? Register   Sign In
Variables not showing up in View
#2

[eluser]gtech[/eluser]
when you load a view you need to pass in an associative array, the keys then become available as variable names.. like so:

Code:
$dataarr = array();
$dataarr['var1'] = 'value1';
$dataarr['var2'] = 'value2';
$this->load->view('viewname',$dataarr);
then in the view you will have the variables
Code:
<?=$var1?>
<br>
&lt;?=$var2?&gt;
which will print out

value1
value2

note &lt;?=$var1?&gt; is the same as &lt;?php echo $var1 ?&gt;


Messages In This Thread
Variables not showing up in View - by El Forum - 05-27-2008, 10:47 AM
Variables not showing up in View - by El Forum - 05-27-2008, 11:11 AM
Variables not showing up in View - by El Forum - 05-27-2008, 11:32 AM
Variables not showing up in View - by El Forum - 05-27-2008, 11:55 AM



Theme © iAndrew 2016 - Forum software by © MyBB