Welcome Guest, Not a member yet? Register   Sign In
can not pass varibles to view
#6

Hi there

Change your controller as

class Hello extends CI_Controller{
protected $name=''; //or can be public / private depending on your scope
protected $color='';
public __construct(){
parent::__construct();
$this->name='test';
$this->color='red';
}
function view()
{
$data['name']=$this->name;
$data['color']=$this->color;
$this->load->view('view',$data);
}
}//end hello class
//then in your view
change it to:
Hai <font color="<?= $color ?>"> <?= $name ?> </font><!--Note the equal sign in front of name is needed -->

OR
Hai <font color="<?php echo $color ?>"><?php echo $name ?></font>

This should work!
Reply


Messages In This Thread
can not pass varibles to view - by munna - 02-22-2015, 02:55 AM
RE: can not pass varibles to view - by InsiteFX - 02-22-2015, 05:17 AM
RE: can not pass varibles to view - by Avenirer - 02-22-2015, 01:45 PM
RE: can not pass varibles to view - by Muzikant - 02-22-2015, 02:00 PM
RE: can not pass varibles to view - by Muzikant - 02-22-2015, 02:20 PM
RE: can not pass varibles to view - by dbui - 02-22-2015, 02:28 PM
RE: can not pass varibles to view - by dbui - 02-22-2015, 02:36 PM



Theme © iAndrew 2016 - Forum software by © MyBB