Welcome Guest, Not a member yet? Register   Sign In
[Beginner] output order of views/controller code on page and HTML Table Class tag attribute support
#3

[eluser]Federico BaƱa[/eluser]
I'd put the database query into a model (no matter how simple it is) first.
Then i'd create a third view for the table, and then load header, table_view and footer on the controller.

Here's a short snippet
Code:
// Model
class Contacts_model extends Model {

    ...

    function get_contacts()
    {
        $query = $this->db->get('local_group_contacts');

        if ($query->num_rows() > 0) {
              return $query->result();
        }
        
        return array();
    }

}

Code:
// Controller
function index()
{
     ... load model
     ... load table library
     $data = array('table' => $this->table->generate());
     ... load header
     $this->load->view('table_view', $data);
     ... load header
}

Code:
// Table View
<?php echo $table; ?>


Messages In This Thread
[Beginner] output order of views/controller code on page and HTML Table Class tag attribute support - by El Forum - 12-27-2010, 07:57 AM



Theme © iAndrew 2016 - Forum software by © MyBB