hi

i am new to codigniter...
i fetch records from db and want to access it in another functio in same class but it giving me error.. any idea...

class Usercp_Task extends CI_Controller {
    var $cate=array();
    public function index() {
        $this->getCategoryDetails();
    }
    public fun getCategoryDetails()
    {
         $array_db=result form database...
         $this->$cate=$array_db;
    }
    public fun showcategory()
    {
         print_r($cate);
    }

thanx

In CI you should use a model to do this kind of tasks, but you can pack the result to a string and return that, just use true as third parameter in $this->load->view :

$string = $this->load->view('my_view',$data,true);

A full example would be:

public function test()
{
    $data['a'] = 'hello world!';
    $string = $this->load->view('first_view',$data,true);
    return $string;
}
    
public function hello()
{
    $data['read'] = $this->test();
    $this->load->view('second_view',$data);
}

Bye :)