Basic steps to start codeIgniter application

Basic steps to start codeIgniter application
1. Download the codeigniter from official website. https://www.codeigniter.com/
2. Downloaded folder extract and rename the folder name and place in side htdocs folder in your local server.
3. See the application folder, here you can observe MVC structure like controllers,models and views.
4. Inside Application folder that has config folder available , you have to config base_url and index_page.
Path: application/config/config.php
5. Configure your web application databse details at : application/config/database.php
6. In Codeigniter routing is very important. Default route for web application.
$route[‘default_controller’] = “Welcome”;
$route[‘404_override’] = ”;

For handling the form data you have to ser TRUE instead of FALSE in config.php
Global XSS Filtering.
$config[‘global_xss_filtering’] = TRUE;

7. Set the autoload libraries,database and helpers like form,url…

array_slice function for array pagination

array_slice function we will use for array pagination to get some part of array

$items = array(1,2,3,4,5,6,7,8,9,10);
$limit = 3;

$qty_items = count($items);
$qty_pages = ceil($qty_items / $limit);

$curr_page = isset($_GET[‘page’]) ? $_GET[‘page’] : 1;
$next_page = $curr_page < $qty_pages ? $curr_page + 1 : null;
$prev_page = $curr_page > 1 ? $curr_page – 1 : null;

$offset = ($curr_page – 1) * $limit;
$items = array_slice($items, $offset, $limit);

$items // Array of elements

$offset // how many elements leave at the time of fetching

$limit //get number of elements from array

Pagination code

for($i = 1; $i <= $qty_pages; $i++){

echo $i;

}

ceil() function return integer number.