Tag: Codeigniter

CSV (Comma Separated Values ) is the most popular file format for data import and export within the project.

In PHP for creating CSV file, you can either use fputcsv() method or directly write the comma-separated content on the file.

In this tutorial, I will show you how you can export MySQL data in CSV file format in your CodeIgniter project.

Export MySQL data to CSV file in CodeIgniter

PHP

Dynamically dependent dropdown commonly seen in the country, state, and city selection on the webpage. The data on the child element changes according to the value of the parent element.

The process follows the same way if there are more than 2 dropdown elements.

To do this you can either use only PHP or jQuery AJAX.

In this tutorial, I am using jQuery AJAX to make dynamic dependent dropdown.

Dynamic dependent dropdown in CodeIgniter with AJAX

AJAX Jquery PHP

A route is a way to remapping, makes more meaningful and SEO friendly URLs. The visitor views the newly generated page URL and the route calls the defined action URL which will be hidden from the visitors.

In CodeIgniter, a URL consists of controller-name/method-name but you can manipulate it by declaring routing.

All routed actions will be written on the specific file.

How to route a URL in CodeIgniter

How To PHP

Pagination on the page improves the user experience when there is a large number of records are available.

CodeIgniter has provided a library for effectively handle the pagination functionality.

In this tutorial, I am using the pagination library to create the paginated list of fetched result from MySQL database.

Make pagination with CodeIgniter Framework

PHP

Handle session is very important when creating a member based website where the user needs to register and login to their account to access website content.

With the help of session, it is easier to identify the user and display the content accordingly.

In Codeigniter, require loading session library to start work with Session. There are inbuilt methods are available that makes easier to handle session operations.

How to handle session in Codeigniter

How To PHP

The Codeigniter allows us to perform the database action like – select, insert, update, and delete with the minimal script.

The $this->db->update() method is used for update existing record. It takes table name and an array or object as the parameter.

In the demonstration, I am listing the user’s list with the edit option. Show the update form on edit option click.

Update records in Database Table with CodeIgniter

DataBase PHP

CodeIgniter have an inbuilt upload library that allows to upload file.  You can specify various preference like – destination path, valid file types, max file size, etc.

In this tutorial, I create a simple example to demonstrate file uploading in CodeIgniter.

How to upload file in CodeIgniter

PHP

All logical operation and database handling done in the Models like insert, update or fetch records.

Codeigniter has predefined Database methods to perform database request.

In the demonstration, with View show the HTML form and when the user submits the forms then call the Model method to insert record from the controller.

Insert record to Database Table - Codeigniter

PHP

Codeigniter is a lightweight PHP-based framework to develop the web application. It is based on MVC (Model View Controller) pattern.

  • The model handles the data processing – Return data, Insert, Update, or delete records from Database Table.
  • The view displays the final output.
  • The controller manages the Model and view. It handles the users’ inputs.

In this tutorial, I cover basis about Codeigniter.

How to install and setup Codeigniter

PHP