Welcome Guest, Not a member yet? Register   Sign In
Poll: Is this help to you.
You do not have permission to vote in this poll.
Yes
50.00%
1 50.00%
No
50.00%
1 50.00%
Total 2 vote(s) 100%
* You voted for this item. [Show Results]

Simple MVC example.
#1
Thumbs Up 

In this post I will show you how to do basic MVC examples.


Step 01 :

Frist I will create my controller.
So create a file called name.php in \CodeIgniter\application\controllers directory.

And paste the below codes.

<?php

class name extends CI_Controller{

public function getName()
{

$this->load->model('nameModel');
$data['info']=$this->nameModel->getName();

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

}

}


?>

Step 02 :

Now I need my model.Create nameModel.php inside \CodeIgniter\application\models directory.
And save the below set of codes in it.

<?php

class nameModel extends CI_Model{


public function getName()
{

$name="Ujitha";

return $name;


}



}

?>

Step 03 :

Now what I need to do is to view the data to the user.

Create a php file in \CodeIgniter\application\views directory as name.php

save below codes in it.

<?php

echo $info;

?>

Step 04 :

That is all..

Go to the web browser and type the below in address bar(N.B->Here I use the WAMP server.).

http://localhost/Codeigniter/index.php/name/getName


You will have below attached output.
That is my style with Codeigniter Idea . Start with simple and ends in deep.
Reply
#2

Please, don't use the forum as your personal blog ...
Reply




Theme © iAndrew 2016 - Forum software by © MyBB