CodeIgniter Forums
Problem in display (view) - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Problem in display (view) (/showthread.php?tid=10243)



Problem in display (view) - El Forum - 07-23-2008

[eluser]johnmiller[/eluser]
Hey...

I have a table called 'users' with fields 'name, address'.

There are 100 records in this table.

I need to display all the 100 records in the 'view'.

But I am getting only one record(first record).

How to write the view which displays all the 100 records?

Can you please help me?

The below given are the model and controller

Model (blogmodel.php)

Code:
<?php

class Blogmodel extends  Model {

function select_entries()
{
    $this->db->select('name, address');
    $query = $this->db->get('users');
    return $query->row_array();

}
}
?>

Controller (blog.php)

Code:
<?php

class Blog Extends Controller {

function index()
{  
    $this->load->model('blogmodel');
    $data['query'] = $this->blogmodel->select_entries();
    $this->load->view('blogview', $data);
}
}

?>



Problem in display (view) - El Forum - 07-23-2008

[eluser]jcopling[/eluser]
I believe that you are wanting the function result_array() rather than row_array().

The row() and row_array() functions simply return the first result.


Problem in display (view) - El Forum - 07-23-2008

[eluser]cyr0715[/eluser]
http://ellislab.com/codeigniter/user-guide/database/results.html