Welcome Guest, Not a member yet? Register   Sign In
Assist adding G-chart into my application
#5

Here are a simple example for fetching data and print it in the view.
Model (Members_model.php)
PHP Code:
class Members extends CI_Model {
    public function 
get($id false)
    {
        if (
$id)
        {
            
$this->db->where('member_id'$id);
        }
        
$this->db->order_by('member_id''asc');
        
$query $this->db->get('member');
        if(
$query->num_rows() > 0)
        {
            return 
$query->result_array();
        }
        return 
false;
    }



Controller (Members.php
PHP Code:
class Members extends CI_Controller {

    public function 
__construct()
    {
        
parent::__construct();
        
$this->load->model('members_model');
    }

    public function 
index()
    {
        
$this->data['members'] = $this->members_model->get();
        
$this->load->view('members'$this->data);
    }




View (members.php)
PHP Code:
<?php foreach($members as $member): ?>
    <?php print_r($member); ?>
<?php 
endforeach; ?>

Reply


Messages In This Thread
RE: Assist adding G-chart into my application - by Rufnex - 11-12-2014, 05:38 AM



Theme © iAndrew 2016 - Forum software by © MyBB