从数据库获取输入

i'd like to ask if i'm doing it right.

this is my code in my model:

function member_here()
{
$this->db->select('first_name');
$this->db->from('membership');
$this->db->where('username', 'username');

$q=$this->db->get();

if($q->num_rows() > 0) 
{
foreach($q->result() as $row) {
$data[]=$row;
    }
    return $data;
}
}

then, this is my code in my view:

    $CI =& get_instance();
$CI->load->model('membership_model');
$result = $CI->membership_model->member_here();
var_dump($result);

I'm quite confused because, if i log in, my name doesn't appear in the page. anyway, if my code is wrong. how do i output SOME of the information from the database i am using?

Thanks in advance!

if($q->num_rows() > 0) {
    $data = array();
    foreach($q->result() as $row) {
        $data[]=$row;
    }
    return $data;
}

You need to initialize the $data variable before push into it..