Welcome Guest, Not a member yet? Register   Sign In
how to pass query result from controller to view and display it?
#1

[eluser]Alpha[/eluser]
hi im new, i have $data & $query object, how to display my query object in my view file?

$data['keywords'] = "keys";
$data['description'] = "descript";

$query = $this->db->query('SELECT id, title, body FROM my_table');

$this->load->view('index', $data);
$this->load->view('index', $query);

in my view file

<?php
foreach ($query->result() as $row)
{
echo $row->id;
echo $row->title;
echo $row->body;
}?>

the above doesn't work, need help tnx


Messages In This Thread
how to pass query result from controller to view and display it? - by El Forum - 07-16-2011, 05:04 AM



Theme © iAndrew 2016 - Forum software by © MyBB