Google column chart using Codeigniter

We know that Google chart basically displays different statistical data on different chart types such as column chart, bar chart, line chart, pie chart etc. You can have a look at the URL for more information.

In my previous tutorial the year value was always showing as 2k for 2010, 2011, 2012 etc. Now I have updated the code a little bit so that it will show the exact year on horizontal axis.

You can integrate Google chart with any server side technology but here I will show you how to integrate Google chart with Codeigniter. This tutorial shows step by step so that we can understand how it happens. It displays the data for Company Performance for last five years in bar(column) chart. You can also use other charts for any purpose. In this example I have used data coming from database. You can change the source of data as per your requirements.

If you have any query please feel free to leave a comment. Continue reading “Google column chart using Codeigniter”

Codeigniter Join Example

This tutorial will show you how we can use Codeigniter’s Query Builder Class to build join queries for fetching data from multiple tables.

The SQL Join clause is used to combine records together from two or more tables in a database. A JOIN locates related column values in two or more tables. This will display all the records that have matched. Join and Inner Join are functionally equivalent, but INNER JOIN can be a bit clearer to read, especially if the query has other join types (i.e. LEFT or RIGHT or CROSS) included in it. Here we will see Join or Inner Join example.

We will use Codeigniter’s $this->db->join() that permits you to write the JOIN portion of your query.

Read also Codeigniter Full Outer Join Example ,  Codeigniter Right Outer Join Example and Codeigniter Left Outer Join Example


Netbeans 8.1
XAMPP in Windows
Codeigniter 3.0.6

Continue reading “Codeigniter Join Example”

Prevent SQL Injection in Codeigniter

This tutorial will show you how to prevent SQL injection in Codeigniter application.

SQL injection is:

a malicious code injection technique that may destroy your database.

one of the most common web hacking techniques.

the placement of malicious code in SQL statements, via input fields in web page.

It is very important to escape the variable you pass by when using to the database query because in web application security SQL injections play an important role.

We usually use mysql_real_escape_string() function to prevent SQL injections, but we do not need to use this function in case of Codeigniter. In Codeigniter we have different ways such as Escaping Queries, Query Binding and Active Record to prevent SQL injection in Codeigniter.

The following reference has been taken from Codeigniter documentation.

Escaping Queries

It’s a very good security practice to escape your data before submitting it into your database. CodeIgniter has three methods that help you do this: Continue reading “Prevent SQL Injection in Codeigniter”

File upload example in Codeigniter 2.1.4

File upload example in Codeigniter 2.1.4. There is file upload class, in codeigniter, which permits you to upload the file or files. This class also permits you to set various preferences such as destination where the file will be uploaded, restrition on file types, restriction on file size, whether a file name should be encrypted or not, maximum length of the file name etc.

Below are the simple few processes for uploading a file

A form with input type file is required so that user can select the file using the browse button
When the form is submitted, the file is validated to make sure that the file is uploaded against the preferences you set
Once the file is uploaded successfully to the specified destination, the success message is shown Continue reading “File upload example in Codeigniter 2.1.4”