How to retrieve data from mysql and display in codeigniter view?

As you all are know codeigniter is an MVC framework, now by using model, view and controller we will retrieve data from mysql table and display in codeigniter view.

I had taken a small table with firstname, lastname and emailed. Now I will create a controller function. Here from below diagram you will get an overview how Model, view and controller works.

codeigniter MVC functionality

Now create controller file under applications/controller/welcome.php ,open the controller file copy
below code there.

lamborghini gallardo hire

Now let’s check model file, create file under applications/model/ektreemodel.php.
Open the file and copy below code in the model file.

Now finally create a view under applications/views/fetchdata.php,Open the file and copy the below code in view.

Now finally open the xampp and start apache and mysql servers. And then go to browser and type localhost:/projectname/index.php/controller_name/function_name
Example: localhost:/codeigniter/index.php/welcome/fetchdata

Now you will get output as below…

Codeigniter view output

Thanks for reading this article ,feel free to post your comments below for any issues.

Saritha Reddy

I am Saritha Reddy, a Remote codeigniter,Angularjs Developer. I have 4+ years of strong experience in designing, implementing, Programming and delivering advanced XAMPP ( Apache, MySQL and PHP) Web applications development. I am an Indian national and based Andhra Pradesh,Hyderabad. In addition to providing custom programming and design, I also have extensive experience with Open Source technologies to keep costs down and get websites running with as little fuss and wait as possible.

More Posts

Follow Me:
TwitterFacebookGoogle Plus

1 Comment

  1. Radenko Kosic

    Excellent!

    Reply

Leave a Comment

Your email address will not be published. Required fields are marked *