Welcome Guest, Not a member yet? Register   Sign In
how to call my model function in view page?

HI All,
hopefully CI is very useful for PHP programmer.
I created one function in my model class.
i want to call this function into my view page.
Example code:
class Newmodel extends Model
function Newmodel()
function getName()
echo "suba";
}//end class
My view page.
i loaded model class in my controller using $this->load->model('newmodel').
here i want to call getName function. How to call? please help to me.


If you autoload your model in application/config/autoload

you can then access it like this:

<php echo $this->modelname->getname();?&gt;

or you can get it in your Controller and pass it to your view like this:

var $data = array();

function index
    $data['name'] = $this->model->getname();

    $this->load->view('viewname', $data);

In your view:

&lt;?php echo $name;?&gt;


thanks. very much.
will try this..
lot of thanks..

i want to pass argument from view page.
what is the execution process.?
please explain how to execute this?

Theme © iAndrew 2016 - Forum software by © MyBB