Insert and List the data in codeigniter

By | March 25, 2016

Its a simple student entry form and listing of the entered students.You can follow the below steps to do this

Step1: create a database named (studentdatabase) in the mysql using phpmyadmin. Below query u can execute through phpmyadmin

Step2: Configuration changes in different pages.

In Application/config/routes.php
$route[‘default_controller’] = “register”;
default_controller will be a “welcome” controller in a fresh codeigniter. here i m changed the default_controller to register.

In Application/config/database.php

In Application/config/config.php

changed the base_url as like below. if you are running the application inside htdocs folder of XAMPP or WAMP server,can give any name for the folder. here the name of the folder is ‘school’.

In Application/config/autoload.php

above mentioned helpers,model and libraries are used in the application.

Click to see the Demo

Click here to see the detailed code and demo

Step3: Creation of controller. here i created a controller called register.php. path of this file will be inside application/controller/register.php

Step4:View file creation-created three view files inside views/register folder

Three view files usage and code as below

register_main.php- This is used to display the main page of the application. This is a simple html page layout to display the student add,student list links

register_student.php- This pages shows the student entry form. function name of the controller is specified in the form action page.

list_student.php- This page is used to display the student details.

Step5: creation of model file in the application/model/student_model.php. This file contains the database query to fetch the student details from tbl_student.

Click to see the Demo

Click here to see the detailed code and demo