Welcome Guest, Not a member yet? Register   Sign In
noob here. please help me regarding "Creating and Sending Parameters Between Controller and View"
#1

[eluser]tunabelly14[/eluser]
hey guys im new in codeignter and php programming. I'am following the tutorial in this link. "http://www.phpeveryday.com/articles/CodeIgniter-Creating-and-Sending-Parameters-Between-Controller-and-View-P150.html"

//this is the code i am using to my controller
<?php
class Hello extends Controller{
var $name;
var $color;

function Hello()
{
parent::Controller();
$this->name = 'Andi';
$this->color= 'red';
}

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


//while this is my code to my view folder
<html>
<head>
<title>hello</title>
</head>
<body>
hello!
<font color="&lt;?=$color?&gt;">&lt;?=$name?&gt;</font>!
&lt;/body&gt;
&lt;/html&gt;


//then the output is only
hello!
(it doesn't show the word Andi)
please help me guys. Thank you in advance!
#2

[eluser]InsiteFX[/eluser]
Use &lt;?php not &lt;?=

Short tags are likely turned off!

InsiteFX
#3

[eluser]danmontgomery[/eluser]
Are you using CI 1.7.x or 2.0.x?
#4

[eluser]dUspan[/eluser]
yeah

use &lt;?php echo ?&gt;

Big Grin
#5

[eluser]tunabelly14[/eluser]
Thank you for the reply. But I already tried using echo but it is still not working.
@mr.noctrum- im using CI 1.7
#6

[eluser]John_Betong_002[/eluser]
Try this in your view:
Code:
<font color=”&lt;?=$this->color;?&gt;”>&lt;?=$this->name;?&gt;</font>!

// or this
<font color=”&lt;?php echo $this->color;?&gt;”>&lt;?php echo $this->name;?&gt;</font>!
&nbsp;
works for me Smile
&nbsp;
&nbsp;




Theme © iAndrew 2016 - Forum software by © MyBB