Step 1: Download Fresh Codeigniter 3
In First step we will download fresh version of Codeigniter 3, so if you haven't download yet then download from here : Download Codeigniter 3.
Step 2: Create Database and Configuration
In this step we will create new database "test" and add new table "posts" in test database. You can use following SQL Query for create "posts" table. So let's create using bellow sql query:
item table:
After create database and table successfully, we have to configuration of database in our Codeigniter 3 application, so open database.php file and add your database name, username and password.
application/config/database.php
Step 3: Add Route
In this step you have to add one route in our route file. We will manage infinite scroll example on single route using jquery, so let's put route as bellow code:
application/config/routes.php
Step 4: Create Controller
Ok, now first we have to create one new controller AjaxController with index method. so create AjaxController.php file in this path application/controllers/AjaxController.php and put bellow code in this file:
application/controllers/AjaxController.php
Step 5: Create View Files
In this step, we will create two view files as listed bellow:
myPost.php: In this file, we will display layout with infinite ajax jquery.
data.php: In this file, we manage posts table data foreach, so we have to just manage posts data here.
application/views/myPost.php
application/views/data.php
Ok, now we are ready to run our Infinite Scroll example. Make sure you have some dummy records on posts table. So let's run bellow command on your root directory for quick run:
php -S localhost:8000
Now you can open bellow URL on your browser:
http://localhost:8000/my-post