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

(This post was last modified: 02-22-2015, 02:26 PM by Muzikant.)

Munna, try this:

Controller:
PHP Code:
<?php
class Hello extends CI_Controller
{
 public 
$name;
 public 
$color;
 
 public function 
__construct()
 {
 
parent::__construct();
 
$this->name='test';
 
$this->color='red';
 }

 public function 
view()
 {
 
$data['name']=$this->name;
 
$data['color']=$this->color;
 
$this->load->view('view',$data);
 }



View:
PHP Code:
Hai <span style="color: <?=$color?>;"><?=$name?></span>. 

I think, this is what you want. But I recommend you to learn actual HTML/CSS standards and OOP in PHP 5.4+ at first. Good luck.
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