In this example you have database of users table with email and username field and you will use those database table field as a variable in your template.

TEMPLATE VIEW (test_v3.php)






CONTROLLER (test.php)

class Test extends CI_Controller {

function index(){

$UserItems = $this->test_m->get_all_user();

$data = array(
‘blog_title’ => ‘My Blog Title’,
‘blog_heading’ => ‘My Blog Heading’,
‘blog_entries’ => $UserItems

$this->parser->parse(‘test_v3’, $data);




MODEL (test_m.php)


class Test_m extends CI_Model {

function get_all_user() {
$query = $this->db->query(“SELECT username, email FROM users”);
$result = $query->result_array();
return $result;


Read more..Template Parser Class

This entry was posted in CODE IGNITER. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s