• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cannot get value from Controller to View, got undefined variable error.

#1
[eluser]Unknown[/eluser]
Just a simple code to retrieve a single value from db. I can get it show by using echo $data in controller. When i try to echo it in view, there's nothing show.
Here's the error:
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: data
Filename: views/gx_display.php
Line Number: 22


Model:
Code:
function get_v()
{
return $this->db->where('ordering','1')->get('gx')->row()->menu_pic;
}

Controller:
Code:
public function index()
        {
$data = '';
$data = $this->Gx_display_model->get_v();
$this->load->view('gx_display', $data);
        }

View:
Code:
<img src="/img/&lt;?php echo $data;?&gt;" width="580" height="332" border="0" usemap="#Map" name="MAPA01" id="MAPA01">

So, where's the problem?
Thanks for advance!

- Mikanmaozi -






Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.