Saturday, 10 August 2019

Codeigniter 3 - Make CRUD Rest API



Codeigniter is a Simple and Great PHP framework for web application development. There are many cases where Web based application needs communication with other application on web, then at the time we need RESTful API. If your web application has API then it can be very easily communicate with other application, because now API is an essential components of web based application.

What is REST API


We all know REST full form is Representational State Transfer. REST API is on type of Web services which has been use the HTTP different methods like POST, PUT, GET and DELETE for data exchange on the web.

Now in your mind one question arise why need to make API for our web application. If you have make API for you application, then you can easily make mobile app for your web application. Because in mobile app you need to send and received data by using API. There is one other benifits is that by making REST API web services, you can develop web and mobile application be using same database and you can access your data from both web and mobile application at the same time. So, this is the main benifits of developing API for you web application.

In this post we will share this tutorial, in which we will create restful web services in this Codeigniter 3 framework. We will make REST API in Codeigniter which will be used for perform CRUD operation like Insert, Update and Delete mysql data. Here we will not use any Codeigniter library for make CRUD RESTful API, but here we will make CRUD API from scratch. Below you can find step by step process for making CRUD API in Codeigniter.

  • Create Table
  • Make Database Connection
  • Create API Controller
  • Create API Model
  • Create Test API Controller
  • Create View File for Output





Create Table


First we need to make table in your Mysql database, for this you have to run following SQL code in your phpmyadmin. It will make tbl_sample table in your database.


--
-- Database: `testing`
--

-- --------------------------------------------------------

--
-- Table structure for table `tbl_sample`
--

CREATE TABLE `tbl_sample` (
  `id` int(11) NOT NULL,
  `first_name` varchar(250) NOT NULL,
  `last_name` varchar(250) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `tbl_sample`
--
ALTER TABLE `tbl_sample`
  ADD PRIMARY KEY (`id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `tbl_sample`
--
ALTER TABLE `tbl_sample`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;




Make Database Connection


Once you have creating table in your mysql database, Now you have to go to your Codeigniter working folder, and open application/config/database.php and under this you have define your mysql database configuration.


<?php

$active_group = 'default';
$query_builder = TRUE;

$db['default'] = array(
 'dsn' => '',
 'hostname' => 'localhost',
 'username' => 'root',
 'password' => '',
 'database' => 'testing',
 'dbdriver' => 'mysqli',
 'dbprefix' => '',
 'pconnect' => FALSE,
 'db_debug' => (ENVIRONMENT !== 'production'),
 'cache_on' => FALSE,
 'cachedir' => '',
 'char_set' => 'utf8',
 'dbcollat' => 'utf8_general_ci',
 'swap_pre' => '',
 'encrypt' => FALSE,
 'compress' => FALSE,
 'stricton' => FALSE,
 'failover' => array(),
 'save_queries' => TRUE
);

?>


Create API Controller


Now we need to start How to make RESTful API web services in Codeigniter framework. So first we need to make API controller for send and received API http request. This class will received HTTP request for send data in JSON format and received data by using different HTTP request. In this class, we have make following method for handle HTTP request.

__construct() - This is PHP magic function, this function will be execute when object of this class has been created and it will load API model and Codeigniter form library.

index() - This method has been received API request for fetch all data from Mysql table and return all data to HTTP request in JSON format.

insert() - This method has been used for insert or add data into Mysql table, it will received api request for insert or add data into mysql table, and send response in JSON string format.

fetch_single() - This method has been used for fetch single record from mysql table based on value of id and return data in JSON format.

update() - This method of API class has been received request for update or Edit Mysql table data.

delete() - This method has received request for Delete or remove data and it will give reponse in JSON format.

application/controllers/Api.php

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Api extends CI_Controller {

 public function __construct()
 {
  parent::__construct();
  $this->load->model('api_model');
  $this->load->library('form_validation');
 }

 function index()
 {
  $data = $this->api_model->fetch_all();
  echo json_encode($data->result_array());
 }
 
 function insert()
 {
  $this->form_validation->set_rules("first_name", "First Name", "required");
  $this->form_validation->set_rules("last_name", "Last Name", "required");
  $array = array();
  if($this->form_validation->run())
  {
   $data = array(
    'first_name' => trim($this->input->post('first_name')),
    'last_name'  => trim($this->input->post('last_name'))
   );
   $this->api_model->insert_api($data);
   $array = array(
    'success'  => true
   );
  }
  else
  {
   $array = array(
    'error'    => true,
    'first_name_error' => form_error('first_name'),
    'last_name_error' => form_error('last_name')
   );
  }
  echo json_encode($array, true);
 }

 function fetch_single()
 {
  if($this->input->post('id'))
  {
   $data = $this->api_model->fetch_single_user($this->input->post('id'));
   foreach($data as $row)
   {
    $output['first_name'] = $row["first_name"];
    $output['last_name'] = $row["last_name"];
   }
   echo json_encode($output);
  }
 }

 function update()
 {
  $this->form_validation->set_rules("first_name", "First Name", "required");
  $this->form_validation->set_rules("last_name", "Last Name", "required");
  $array = array();
  if($this->form_validation->run())
  {
   $data = array(
    'first_name' => trim($this->input->post('first_name')),
    'last_name'  => trim($this->input->post('last_name'))
   );
   $this->api_model->update_api($this->input->post('id'), $data);
   $array = array(
    'success'  => true
   );
  }
  else
  {
   $array = array(
    'error'    => true,
    'first_name_error' => form_error('first_name'),
    'last_name_error' => form_error('last_name')
   );
  }
  echo json_encode($array, true);
 }

 function delete()
 {
  if($this->input->post('id'))
  {
   if($this->api_model->delete_single_user($this->input->post('id')))
   {
    $array = array(
     'success' => true
    );
   }
   else
   {
    $array = array(
     'error' => true
    );
   }
   echo json_encode($array);
  }
 }
 
}


Create API Model


This API model class has been used for perform API request database side operation. This class has been received request from API controller for Database related query. In this class we have make following method.

fetch_all() - This method has been used for fetch all data from mysql table and send all data to API controller index() mehtod.

insert_api($data) - This is second method of API Model class, and this method will be used for insert or add data related database operation.

fetch_single_user($user_id) - This method is used for Database related operation of select single records from Mysql table.

update_api($user_id, $data) - This method of Models class has been used for Mysql Database Update or Edit operation.

delete_single_user($user_id) - This method has been used for perform Delete or Remove Database crud operation.

application/models/Api_model.php

<?php
class Api_model extends CI_Model
{
 function fetch_all()
 {
  $this->db->order_by('id', 'DESC');
  return $this->db->get('tbl_sample');
 }

 function insert_api($data)
 {
  $this->db->insert('tbl_sample', $data);
  if($this->db->affected_rows() > 0)
  {
   return true;
  }
  else
  {
   return false;
  }
 }

 function fetch_single_user($user_id)
 {
  $this->db->where("id", $user_id);
  $query = $this->db->get('tbl_sample');
  return $query->result_array();
 }
 function update_api($user_id, $data)
 {
  $this->db->where("id", $user_id);
  $this->db->update("tbl_sample", $data);
 }
 
 function delete_single_user($user_id)
 {
  $this->db->where("id", $user_id);
  $this->db->delete("tbl_sample");
  if($this->db->affected_rows() > 0)
  {
   return true;
  }
  else
  {
   return false;
  }
 }
}


Create Test API Controller


Above we have make RESTful API for perform CRUD operation. Now need to test that API, so here we have make one another controller for test our RESTful API web services. For check API working or not here we have make some method, which has send HTTP request to API controller for different operation. In this class, we have make following method.

index() - This is the root method of this controller class. This method has load api_view.php file in browser.

action() - This is another method of this Test_Api.php Class. First in this method we have define api url and then after we have use cURL library for send HTTP request to API class for send and received data.

application/controllers/Test_api.php

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Test_api extends CI_Controller {

 function index()
 {
  $this->load->view('api_view');
 }

 function action()
 {
  if($this->input->post('data_action'))
  {
   $data_action = $this->input->post('data_action');

   if($data_action == "Delete")
   {
    $api_url = "http://localhost/tutorial/codeigniter/api/delete";

    $form_data = array(
     'id'  => $this->input->post('user_id')
    );

    $client = curl_init($api_url);

    curl_setopt($client, CURLOPT_POST, true);

    curl_setopt($client, CURLOPT_POSTFIELDS, $form_data);

    curl_setopt($client, CURLOPT_RETURNTRANSFER, true);

    $response = curl_exec($client);

    curl_close($client);

    echo $response;




   }

   if($data_action == "Edit")
   {
    $api_url = "http://localhost/tutorial/codeigniter/api/update";

    $form_data = array(
     'first_name'  => $this->input->post('first_name'),
     'last_name'   => $this->input->post('last_name'),
     'id'    => $this->input->post('user_id')
    );

    $client = curl_init($api_url);

    curl_setopt($client, CURLOPT_POST, true);

    curl_setopt($client, CURLOPT_POSTFIELDS, $form_data);

    curl_setopt($client, CURLOPT_RETURNTRANSFER, true);

    $response = curl_exec($client);

    curl_close($client);

    echo $response;







   }

   if($data_action == "fetch_single")
   {
    $api_url = "http://localhost/tutorial/codeigniter/api/fetch_single";

    $form_data = array(
     'id'  => $this->input->post('user_id')
    );

    $client = curl_init($api_url);

    curl_setopt($client, CURLOPT_POST, true);

    curl_setopt($client, CURLOPT_POSTFIELDS, $form_data);

    curl_setopt($client, CURLOPT_RETURNTRANSFER, true);

    $response = curl_exec($client);

    curl_close($client);

    echo $response;






   }

   if($data_action == "Insert")
   {
    $api_url = "http://localhost/tutorial/codeigniter/api/insert";
   

    $form_data = array(
     'first_name'  => $this->input->post('first_name'),
     'last_name'   => $this->input->post('last_name')
    );

    $client = curl_init($api_url);

    curl_setopt($client, CURLOPT_POST, true);

    curl_setopt($client, CURLOPT_POSTFIELDS, $form_data);

    curl_setopt($client, CURLOPT_RETURNTRANSFER, true);

    $response = curl_exec($client);

    curl_close($client);

    echo $response;


   }





   if($data_action == "fetch_all")
   {
    $api_url = "http://localhost/tutorial/codeigniter/api";

    $client = curl_init($api_url);

    curl_setopt($client, CURLOPT_RETURNTRANSFER, true);

    $response = curl_exec($client);

    curl_close($client);

    $result = json_decode($response);

    $output = '';

    if(count($result) > 0)
    {
     foreach($result as $row)
     {
      $output .= '
      <tr>
       <td>'.$row->first_name.'</td>
       <td>'.$row->last_name.'</td>
       <td><butto type="button" name="edit" class="btn btn-warning btn-xs edit" id="'.$row->id.'">Edit</button></td>
       <td><button type="button" name="delete" class="btn btn-danger btn-xs delete" id="'.$row->id.'">Delete</button></td>
      </tr>

      ';
     }
    }
    else
    {
     $output .= '
     <tr>
      <td colspan="4" align="center">No Data Found</td>
     </tr>
     ';
    }

    echo $output;
   }
  }
 }
 
}

?>


Create View File for Output


In Codeigniter framework, view file mainly used for display output HTML output in browser. So here also this file has been used for display API output in browser. Here we have use jQuery and Bootstrap library. Here we want to make single page application by using API in Codeigniter framework. So here we have use Bootstrap model for insert or update data. In this file we have also use Ajax request for perform CRUD operation request.

application/views/api_view.php

<html>
<head>
    <title>CURD REST API in Codeigniter</title>
    
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
    
</head>
<body>
    <div class="container">
        <br />
        <h3 align="center">Create CRUD REST API in Codeigniter - 4</h3>
        <br />
        <div class="panel panel-default">
            <div class="panel-heading">
                <div class="row">
                    <div class="col-md-6">
                        <h3 class="panel-title">CRUD REST API in Codeigniter</h3>
                    </div>
                    <div class="col-md-6" align="right">
                        <button type="button" id="add_button" class="btn btn-info btn-xs">Add</button>
                    </div>
                </div>
            </div>
            <div class="panel-body">
                <span id="success_message"></span>
                <table class="table table-bordered table-striped">
                    <thead>
                        <tr>
                            <th>First Name</th>
                            <th>Last Name</th>
                            <th>Edit</th>
                            <th>Delete</th>
                        </tr>
                    </thead>
                    <tbody>
                        
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</body>
</html>

<div id="userModal" class="modal fade">
    <div class="modal-dialog">
        <form method="post" id="user_form">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                    <h4 class="modal-title">Add User</h4>
                </div>
                <div class="modal-body">
                    <label>Enter First Name</label>
                    <input type="text" name="first_name" id="first_name" class="form-control" />
                    <span id="first_name_error" class="text-danger"></span>
                    <br />
                    <label>Enter Last Name</label>
                    <input type="text" name="last_name" id="last_name" class="form-control" />
                    <span id="last_name_error" class="text-danger"></span>
                    <br />
                </div>
                <div class="modal-footer">
                    <input type="hidden" name="user_id" id="user_id" />
                    <input type="hidden" name="data_action" id="data_action" value="Insert" />
                    <input type="submit" name="action" id="action" class="btn btn-success" value="Add" />
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                </div>
            </div>
        </form>
    </div>
</div>

<script type="text/javascript" language="javascript" >
$(document).ready(function(){
    
    function fetch_data()
    {
        $.ajax({
            url:"<?php echo base_url(); ?>test_api/action",
            method:"POST",
            data:{data_action:'fetch_all'},
            success:function(data)
            {
                $('tbody').html(data);
            }
        });
    }

    fetch_data();

    $('#add_button').click(function(){
        $('#user_form')[0].reset();
        $('.modal-title').text("Add User");
        $('#action').val('Add');
        $('#data_action').val("Insert");
        $('#userModal').modal('show');
    });

    $(document).on('submit', '#user_form', function(event){
        event.preventDefault();
        $.ajax({
            url:"<?php echo base_url() . 'test_api/action' ?>",
            method:"POST",
            data:$(this).serialize(),
            dataType:"json",
            success:function(data)
            {
                if(data.success)
                {
                    $('#user_form')[0].reset();
                    $('#userModal').modal('hide');
                    fetch_data();
                    if($('#data_action').val() == "Insert")
                    {
                        $('#success_message').html('<div class="alert alert-success">Data Inserted</div>');
                    }
                }

                if(data.error)
                {
                    $('#first_name_error').html(data.first_name_error);
                    $('#last_name_error').html(data.last_name_error);
                }
            }
        })
    });

    $(document).on('click', '.edit', function(){
        var user_id = $(this).attr('id');
        $.ajax({
            url:"<?php echo base_url(); ?>test_api/action",
            method:"POST",
            data:{user_id:user_id, data_action:'fetch_single'},
            dataType:"json",
            success:function(data)
            {
                $('#userModal').modal('show');
                $('#first_name').val(data.first_name);
                $('#last_name').val(data.last_name);
                $('.modal-title').text('Edit User');
                $('#user_id').val(user_id);
                $('#action').val('Edit');
                $('#data_action').val('Edit');
            }
        })
    });

    $(document).on('click', '.delete', function(){
        var user_id = $(this).attr('id');
        if(confirm("Are you sure you want to delete this?"))
        {
            $.ajax({
                url:"<?php echo base_url(); ?>test_api/action",
                method:"POST",
                data:{user_id:user_id, data_action:'Delete'},
                dataType:"JSON",
                success:function(data)
                {
                    if(data.success)
                    {
                        $('#success_message').html('<div class="alert alert-success">Data Deleted</div>');
                        fetch_data();
                    }
                }
            })
        }
    });
    
});
</script>


So, this is step by step guide for build CRUD RESTful API in Codeigniter. So, if you want to learn Simple way for develop API in Codeigniter, then this post will help you.

Wednesday, 7 August 2019

What Every PHP Developer Needs to Know About Cyber Security



PHP which stands for Hypertext Preprocessor is a general-purpose programming language. According to W3techs Web Technology Surveys, at least 79% of websites of the web use PHP as the server-side programming language. In fact, it is way past Java, Ruby, and ASP.NET in market position as well.

Although PHP is a top-ranking and favorite programming language, it faces the same security challenges that everything digital faces. From virus programs to ransomware, websites and web applications built using PHP are not immune to cyber security threats.

Moreover, security is not child’s play either. It is complex, constantly changing and requires patience to set up and monitor.

If you are a PHP developer, you know what I am talking about.

The problem with PHP development is that the entry of barrier is literally zero. Anybody with interest in the framework can become a developer.

The newbies who join the PHP developer workforce are unaware of the risks caused by the mistakes that they make. In this article, I have outlined some such mistakes below:

Playing it easy with admin accounts


Any web admin who has been in the field for some time understands the critical nature of admin accounts. They are like the key a bank’s safety locker. Access to the admin account is all that a hacker needs to take down a website, or worse tweak it to their benefit. As a PHP developer, you must ensure complete security of the admin account before anything else. Do not provide admin access to everyone, keep it limited to certain person.

Not getting trained on cyber security


Cyber security is not something that can learnt once and be done with. Every single day hackers are inventing novel ways of breaking into a system and sneaking away with data. If you want to beat the odds of getting hacked, it is necessary that you get trained on cyber security. It is quite necessary to get SSL certificate when you develop any website in PHP language.



For instance, something very basic as configuring a Wildcard SSL Certificate can help to secure multiple sub domains of a website. Although the website might be small in the initial stages, the Wildcard certificate can help when the number of sub domains are scaled up.

Skimping on password protection


From the log in page to the admin’s account, passwords are the gatekeepers that let in authorized users and stop unauthorized users from gaining access. When PHP developers skimp on password security by allowing users to set weak passwords, they are creating a culture where cyber security is not encouraged. This leads to further cyber security incidents.

To make things easy for you and to do my bit in making the web a safer place for all, I have compiled a list of security best practices. Here it goes:

Update PHP regularly


Like every other CMS platform out there, the engineers at PHP also regularly update the platform. The latest version of PHP is 7.2.8. Studies have already proven that older versions of any CMS are susceptible to attacks and prone to being hacked. So, the first step that you can take towards securing your PHP-based website is to update it regularly.

There are tools that are available online that can help you see whether the version you are using has been deprecated or needs updating.

Some of them are:

Avoid Cross-site scripting (XSS)


Cross-site scripting is a security vulnerability which allows hackers to inject server-side scripts into website’s code. The malicious code allows the hacker to steal information that the user submits to the website. The risk is greater in websites like banking, account-based services and so on where the user’s credentials, account information, etc. could be of monetary value.

The safest bet you can take to prevent XSS is using filters for user input. In other words, you must sanitize every user input before passing it to the website’s server for processing. This would avoid any malicious code from getting into your system.

SQL injection attacks


As the name suggests SQL injection works by injecting malicious SQL codes into a code repository. This would enable the hacker to make a data-driven program to collapse or work in a manner as they desire. For instance, SQL injection attacks are often used to make PHP-based web applications reveal sensitive data like account details of an ecommerce store, personal information of users and so on. To avoid SQL attacks, you should Prepared Statements instead of dynamic SQL queries. Moreover, use of stored procedures that will add extra layer to database.

Hide files from browser


Your PHP web application would have several files that are required to make it run smoothly. These files are often stored on the backend of the application. There are specific frameworks for storing these files, which is not properly selected or configured would let the hackers find their way in to access the files. As a thumb rule, do not store the files in the root directory, instead but in a public folder where they are not easily accessible.

In a nutshell


Becoming a PHP developer brings with it several benefits. But all PHP developers must understand that it takes a whole lot of effort to keep data safe. The groundwork for this must be laid during the development phase itself when security and access controls can be configured proactively.

Best Benefits of PHP Website Development for Online Business



Businesses are developing themselves with technology around the world. It is a known fact online business has more credential one can think. It comes with "designing" and "development" for the website. It is becoming priorities to develop and design a website in new ways for businesses. PHP (Hypertext Pre-processor) is a general-purpose programming language used basically for web development for the site.

PHP is a server-side scripting language; it runs on a web server and designed for making influential pages and applications. Web development services are more secure and provide benefits to a lot more people. It makes it more accessible too. It can also install into HTML.

Many businesses have come around using and benefiting from PHP web development. Primarily, a business accounting firms uses this scripting program for its security reasons. It also helps them with multi-tasking and customization. A PHP website has more to its name, not just a language program. You will see below its benefits for online business.

6 Benefits of PHP Website Development For Online Business


As we know, PHP is used widely for web development. Here are six benefits of PHP website development for online business:

PHP Is A Cost-Effective Method


Whether it is a small or large business, this process is used by all. One of the main reason it is beneficial for everyone is it is absolutely “free.” PHP is an open-source platform which is available to everyone. Online business flourishes when your website has something useful to attract.

It is free and cost-effective at its best. Big businesses can save money on their website development. Small businesses now have something useful for their website development, which is best in what it does. It surely gives magnificent results.

Now Customization Is Pretty Easy


When you hire a website development team, they make it more of a burden than easy work towards the end of it. With PHP, you can have the comfort of customization. It revises and expands functions of your website to more user-friendly.

You will be able to know with time what your business needs. It will help to customize your website with its flexible language. It is a crucial asset every business considers before going into web development.



Enhanced Web Experience for Users




Web experience decides whether your website is worth second shot. PHP helps you in providing enhanced web experience.

It runs smoothly on Windows and Linux or any other operating system. So, you don’t have to invest in providing web experience. It does that for you with minimal cost. You can give enhanced web experience to the visitors on the website.

Security and Safety Is Everything


Online businesses are more prone to hacking; that is why big companies have security team for this reason. But with PHP, you don’t have to worry about this issue. It provides you with high-security measures that will keep away hackers.

PHP development is entirely secure for your website. Small businesses can profit from this language. It is less to worry about the security team for this specific reason.

Easy Modifications for Business




It is crucial to change things from time to time. Modifications are not new in online business. With time changes are essential to match with your users/visitors. PHP web development gives you this opportunity.

With this language, you can make modifications and changes your website needs. Business is the world is with every passing second and with it needs of the consumer. You can make changes for your site whenever the need for it arises.

Codes and Easy Control


Coding is one of the main essences of scripting language. PHP is simple when compared to other scripting languages. Coding is effortless and smooth for us. Business owners worry most of the time for coding gone wrong.

PHP provides secure coding, which makes it more popular in online business. It also helps with intricate coding with support from developers around the world. It is an open-source platform which provides help anytime.

CONCLUSION:


It is well used and popular scripting language within the online business industry. What we can identify after learning all we have- it is free for use to everyone. It is the most significant benefit anybody can have and get profited.

Security is another positive point for this web development program. Developing your website helps you gain more traffic. If it is done right, you can learn many visitations on your website. Web designing is another attraction for your visitors. Evaluate what you need to develop most in the website and work on it.

How to Improve Your SQL Experience with Azure?



In present times, there is an overwhelming amount of data getting generated from different platforms. This leads to peer pressure on organizations of managing cots, optimizing performance and using data from competitive advantages as they look forward to the cloud solutions to deal with this pressure.

Microsoft's Azure is attracting multiple companies as it offers a wide variety of benefits to your databases. Organizations can consider upgrading to Azure SQL for various reasons. One such reason is to upgrade all your out-of-date or unsupported database solutions.

One such example is the end of extended support for SQL Server 2008. Multiple organizations are implementing a strategic imperative to future-proof their enterprises by cloud solutions implementation across the organization. No matter what motivates how your enterprise explores Azure SQL as a database solution, your experience is going to be largely improved when you begin implementing Azure SQL.

In this article, we will be looking at some of the simple ways of using Azure SQL for transforming your organization's SQL experience.

Easy Administration and Simple Setup


The very first way of Azure improving the SQL experience lies within its simplicity. Azure is well known for that physical versions of SQL server which can rather be difficult to administer. All the members of the IT team are specially trained to understand the nuance of deployment and management of the SQL server solution. This includes time-consuming tasks such as database apportion and working across physical systems in the network. With the help of Azure, these critical features are pre-loaded and help you to cut through the hindrance by simply processing your database management.

Azure SQL is not only easy to deploy but it is also easy to migrate data from previous instances of SQL. For instance - SQL Server 2008 and 2008 R2 does not require application code changes which result in no-migration downtime. Such seamless transition makes the Azure platform more appealing to organizations across various industries.



Cost Optimization


Despite providing too many advanced capabilities, Azure SQL is very much cost-effective. When designing Azure SQL, Microsoft had made it a priority to build an attractive platform for small and large businesses. Keeping this motto in mind, they implemented a scaling price-based model where the applications are very easy to migrate and scale up with Azure SQL because of the Microsoft providing a high federated infrastructure with the help of Azure Active Directory.

Due to this, moving to Azure SQL is easier and cost-friendly without any hidden costs. With the automatic upgrades feature, moving to Azure helps you to keep your database simple and up-to-date. By cutting out the extra expenditure to perform these upgrades, the organization can save time and work more effectively.

All-time Availability


Azure SQL offers some advanced levels of availability which SQL server has to struggle to match. The first way Azure SQL accomplishes such an all-time availability is by replication. On an automated basis, Azure SQL replicates each database twice on two various nodes which allows you to scarcely experience any downtime or data loss.

Addition to this, SQL Server needs a manual implementation of the database mirroring and failover clustering. To do so, it requires more efforts from IT teams which are already stretched out to provide an opportunity for detecting errors.

Consistent Reliability


One of the most famous features of Azure SQL is to enable better reliability through continuity. Azure SQL will automatically back up your database and transaction logs to avoid any data loss or error and hence provides an easy way for your organization to restore their database. It also prevents data loss through geo-redundancy where Microsoft's cloud is hosted in remote locations. This keeps your data safe from the events such as natural disasters that can destroy or temporarily take down the traditional data center of your enterprise.

The advanced continuity of Azure SQL simplifies the back-up process and allows your IT teams to restore its database at any point in time. This process allows for easy data restoration by harnessing the power of replication and continuity. Henceforth, you can truly rely on Azure SQL for the databases of your organization.

Wrap Up


Organizations that migrate their databases to Microsoft's Azure SQL by considering a number of benefits provided by it. Azure SQL provides a wide user-friendly and cloud-based database which is more cost-effective for many enterprises to upgrade it. Henceforth, Azure SQL is ensuring that your organization is ready for the future of the cloud and the data stored within it. Till then - Keep Learning!

Author Bio:


Kibo Hutchinson working as a Technology Analyst at Tatvasoft UK. She has a keen interest in learning latest practices in the development so she is spending her most of the time on the Internet navigating the unique topics and technology trends. That’s why she is actively contributing to development, design and latest technologies topics.

Wednesday, 31 July 2019

How to Calculate Total of Column in Datatable using PHP with Ajax

Hi, If you have use jQuery Datatable plugin for display your dynamic data in tabular format on web page, then there are some you have to required to display total of column in footer of Datatable. So, at that time you have one question arise in your mind how to get SUM or total of column in Datatable with Server-side processing by using PHP script and Ajax. In this post, we you can find the solution of Datatable server-side processing for get the total or SUM of column data and display on web page by using PHP Ajax and jQuery. You can do this things on Client Side processing by using different callback function which has been used for manipulated header data of Datatable And by using these type of callback function you have to do various modification for display dynamic total of column.

But here we will use Datatable Server-side processing for make column sum or total. In Server-side processing of data, we will calculate the total of column at server side php script and by using jQuery and Ajax request we will display total or sum of column in footer of Datatable. In Datatable tag has been used for display content of header, tag has been used for display data which has been get from Ajax request in json format and for display DataTable footer content, here we have use tag. This tag has been used for display footer content. So, here also we will display total or sum of column will be display under tag. Below you can find Source code of Column Sum in DataTable by using Server-side processing with PHP Ajax and jQuery.





index.php


This is the main file of this tutorial. In this file we have use javascript library jquery, Bootstrap library and jQuery DataTable library. Under this page we have create on table with id="order_data". We will initialize jQuery Datatable on table by using id attribute value. For display total or sum of column in footer table column, and in that column we have define one id="total_order". We will display sum or column total under this column by using jQuery code.

Under this file you can also finde jquery code for initialize jQuery DataTable plugin. In jquery Code you can see for fetch dynamic data, we have use Ajax request which has send to fetch.php file. For display Sum or total of column we have used drawCallback function. This function has received data from Ajax request, which we can access by using json variable. Below you can find source code of this file below.




<html>
 <head>
  <title>How to Get SUM with Datatable Server-side-processing in PHP</title>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
  <script src="https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js"></script>
  <script src="https://cdn.datatables.net/1.10.12/js/dataTables.bootstrap.min.js"></script>  
  <link rel="stylesheet" href="https://cdn.datatables.net/1.10.12/css/dataTables.bootstrap.min.css" />
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
 </head>
 <body>
  <div class="container box">
   <h3 align="center">How to Get SUM with Datatable Server-side-processing in PHP</h3>
   <br />
   <div class="table-responsive">
    <table id="order_data" class="table table-bordered table-striped">
     <thead>
      <tr>
       <th>Customer Name</th>
       <th>Order Item</th>
       <th>Order Date</th>
       <th>Order Value</th>
      </tr>
     </thead>
     <tbody></tbody>
     <tfoot>
      <tr>
       <th colspan="3">Total</th>
       <th id="total_order"></th>
      </tr>
     </tfoot>
    </table>
    <br />
    <br />
    <br />
   </div>
  </div>
 </body>
</html>

<script type="text/javascript" language="javascript" >
 $(document).ready(function(){
  
   var dataTable = $('#order_data').DataTable({
    "processing" : true,
    "serverSide" : true,
    "order" : [],
    "ajax" : {
     url:"fetch.php",
     type:"POST"
    },
    drawCallback:function(settings)
    {
     $('#total_order').html(settings.json.total);
    }
   });

    
  
 });
 
</script>


fetch.php


This file has receive Ajax request for fetch data from order table. In this file first we have make database connection. After making database connection we have define table column for sorting. Under this file we have make select data query for fetch data from mysql table. Here we have divide select in two part, first part query is for get number of fitered row and whole query will be used for fetch filter data from mysql database. Here we have also calculate the total of order_value table column data. For send column total data to Ajax request, here we have add total key in array which has been send to Ajax request in json data by using json_encode() function. Below you can find source code of this file.


<?php

//fetch.php

$connect = new PDO("mysql:host=localhost;dbname=testing", "root", "");

$column = array('order_customer_name', 'order_item', 'order_date', 'order_value');

$query = '
SELECT * FROM tbl_order 
WHERE order_customer_name LIKE "%'.$_POST["search"]["value"].'%" 
OR order_item LIKE "%'.$_POST["search"]["value"].'%" 
OR order_date LIKE "%'.$_POST["search"]["value"].'%" 
OR order_value LIKE "%'.$_POST["search"]["value"].'%" 

';

if(isset($_POST["order"]))
{
 $query .= 'ORDER BY '.$column[$_POST['order']['0']['column']].' '.$_POST['order']['0']['dir'].' ';
}
else
{
 $query .= 'ORDER BY order_id DESC ';
}

$query1 = '';

if($_POST["length"] != -1)
{
 $query1 = 'LIMIT ' . $_POST['start'] . ', ' . $_POST['length'];
}

$statement = $connect->prepare($query);

$statement->execute();

$number_filter_row = $statement->rowCount();

$statement = $connect->prepare($query . $query1);

$statement->execute();

$result = $statement->fetchAll();

$data = array();

$total_order = 0;

foreach($result as $row)
{
 $sub_array = array();
 $sub_array[] = $row["order_customer_name"];
 $sub_array[] = $row["order_item"];
 $sub_array[] = $row["order_date"];
 $sub_array[] = $row["order_value"];

 $total_order = $total_order + floatval($row["order_value"]);
 $data[] = $sub_array;
}

function count_all_data($connect)
{
 $query = "SELECT * FROM tbl_order";
 $statement = $connect->prepare($query);
 $statement->execute();
 return $statement->rowCount();
}

$output = array(
 'draw'    => intval($_POST["draw"]),
 'recordsTotal'  => count_all_data($connect),
 'recordsFiltered' => $number_filter_row,
 'data'    => $data,
 'total'    => number_format($total_order, 2)
);

echo json_encode($output);


?>


This is one more post on DataTable and here we have discuss how to display Sum or Total of column in DataTable Footer by using Server-side processing with PHP Script, Ajax and jQuery.

Tuesday, 30 July 2019

Ecommerce Product Photography tips: A Beginner’s Guide



At present, the E-Commerce business is increasing day by day. Everyday many people are engaging with an e-commerce business. And product photography is essential for these e-commerce sites. Because without seeing products, clients are not interested in purchasing a product. That's why in e-commerce industry product photography is so much influential thing. If you are a beginner in e-commerce Product Photography, then you can read this article for knowing guidance about E-Commerce Product Photography. Because in this article we will discuss about E-Commerce product photography tips for beginners.

What is Product Photography


Product photography is a branch of photography, which accurately and attractively represents a product in advertising. Product photography uses specific techniques to showcase products in an attractive way and entice potential buyers to purchase particular products. Photography is so principal in selling products. Because all most Ninety-nine percent of all purchases (99!) come from an emotional response, not a need.

People buy things based on how that product will make them feel. We can use this information in creating product images that the viewers will find engaging. That's why product photography is everywhere we look.

The equipment you will need


Photography is a really exciting and interesting thing, but it can also be very confusing for beginner or newcomers. Some new photographer thinks that I will need high tech types of equipment if I want to capture a good image. Actually, this thinking is not right.

At first, you need a camera; You don’t have to buy a fancy camera with a range of lenses to take the correct product image. You can take very professional and polished photos, even with some of the latest smart phones. There are many types of a good camera such as, Whatever camera you choose, get familiar with it before you dive into your first product photography shoot. Then you will need a tripod, a white background, white bounce cards made of foam board, a table, tape, and the right room.



How to photograph your product


If you want to capture your product correctly, then you have to maintain some steps and tips, such as,

1. Set up your table - it’s time to set up your shooting area. Place your table as close to the window as possible without intersecting the shadow from the windowsill. You’ll want to start with the window 90 degrees to the right or left of your setup. The closer you are to the window and the larger the window, the softer the light will be. You do not want direct sunlight hitting your set. Direct sunlight is harsh and looks terrible with your products.

2. Lighting - Lighting is very important. It can change the outlook of the image. If you keep the source of light broader then you will get the light softer and the narrower the source, you will get harder light. With the immense light source, light rays hit your object from different directions; it just opposite of more restricted source. So you should keep proper concentration on lighting.

3. Use sweep - Sweep means creating a clean background. Even if you have a crisp white wall, imperfections can still be seen. To create a clean sweep, all you need is a piece of white paper that sits under your product and sweeps up behind it onto the wall for a seamless look.

4. Set up your camera

5. Set up your product in the middle of the surface - Setting up your product is one of those things that seems simple, but can take time to perfect. If it’s a bag, for example, you have to keep the label type centered. Often there are many tiny movements and adjustments required to get everything lined up perfectly.

6. Shoot from Strange Angles - Usually photographers place the camera at the same level as the product so that the shot comes out at eye-level. Most of the time, you want to be careful about shooting from odd angles, only because it can distort a product.

7. Then take the picture and evaluate - Another importance photography advice to you is to not stop at one photo per product. Just as your clients look, hold, use, and even try on merchandise in a store, your website should shoot a variety of images to simulate this very experience.

8. Finally, you have to edit your image. Because without photoshopping or editing your picture, you cannot be able to attract the attention of target clients. Remember that, photos that feature low resolution, bad lighting, distracting reflections, and a lack of detail aren’t going to convince people to buy what you’re selling. By editing photo, you can solve any tiny problems quickly.

That's why photoshop or image editing is essential for e-commerce product photography. Without proper knowledge about image editing, If you try to edit your photo, then you cannot do it properly. Because many things are related to image editing or photoshop, without professional image editors enough knowledge to gain about photoshop is so tricky. That's why you should go to photoshop service center or professional photoshop services provider. There are many photoshop service providers have in online and offline. They are worked very professionally. If you edit your product photograph by a professional photoshop service provider, then you will get a better result. You cannot do photoshop for image edit like professional photoshop service providers. So by photoshop service provider are edited your product images. It would be beneficial to your e-commerce product photography.

Posting photographs to your website


Make sure your website is displaying the pictures for your products in the highest possible quality, without causing load time. A good rule of thumb tends to be 1MB or under when optimizing your images for web and performance. Similarly, try integrating lifestyle photos to evoke an emotional response from visitors. Lifestyle shots will give your product life and bring about points of connection for clients.

If you follow these tips, steps and guidance, then you can get better feedback as a beginner in e-commerce product photography.



Author

Author Bio:

Salim Ahmed is the founder of Clipping Path Center (CPC), an offshore graphic house for Photoshop Clipping Path services. Besides, he is a Photographer and Blogger. He likes to share tips and tricks on photography, photo editing, and graphic design!

Wednesday, 24 July 2019

Bar or Column Chart using Google Chart in Codeigniter



Now a days display of raw data on Graph or chart is very common this is because Chart or Graph is a graphical representation of data. So, If we are going to see data line by line then it is very difficult to understand what this data tell us. But suppose we have visualize that data on Graph or chart then we can understand what is the output of this. In short Chart or Graph is the small graphical representation of large data. So, it is very important in web development also for display data on Chart or graph. So, Now in this post we are going to discuss topic like How can make dynamic Bar chart or Column chart in Codeigniter framework by using Google Chart Library with Ajax.

Here dynamic chart means we will fetch dynamic data from mysql data and display on Bar chart or Column chart on every Ajax request. So, We will create dynamic column chart from Mysql Database data by using Google chart library in Codeigniter framework with Ajax. We all know display data in Chart format is a basic need of any web application in which admin panel is required. In Admin panel admin has always required chart in his admin panel for get quick data comparison like profit, sales, new buyer or subscriber etc. by using Chart. By using chart admin can get quick comparison of data with filter like month year etc with chart or graph.

For learn this How to Create Dynamic Bar chart or Column in Codeigniter framework by using Google Chart Library with Ajax, here we will create Bar or Column chart for display profit data of year in month-wise format. So, Admin can get the quick profit data of each year in month-wise in single selection of year. Then he can can particular year profit data will be load in chart month wise column. When admin has select year from drop down box, then Ajax request has been trigger which will fetch profit data from mysql database in JSON format and send back to Ajax request, which will called Google Chart Library Function, and in that function it will convert data into Bar or Column chart and display on web page without refresh of web page. So Admin can view any year profit data on web page in Chart format without refresh of web page. Because here we have use Ajax request for fetch data. Below you can find step by step process for creating Bar or Column Chart in Codeigniter framework using Ajax with Google Chart Library.

  • Make Database connection in Codeigniter

  • Define Base Url in Codeingiter

  • Create Controllers in Codeigniter

  • Create Models in Codeigniter

  • Create Views in Codeigniter

  • Check Output in Browser





Make Database connection in Codeigniter


In Codeigniter Application first we want to make table in Mysql database and then after make database connection in Codeigniter. So, run following SQL script in your Mysql database and make table in your database.




--
-- Database: `testing`
--

-- --------------------------------------------------------

--
-- Table structure for table `chart_data`
--

CREATE TABLE `chart_data` (
  `id` int(11) NOT NULL,
  `year` varchar(10) NOT NULL,
  `month` varchar(50) NOT NULL,
  `profit` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `chart_data`
--

INSERT INTO `chart_data` (`id`, `year`, `month`, `profit`) VALUES
(1, '2017', 'January', '50000'),
(2, '2017', 'February', '45000'),
(3, '2017', 'March', '60000'),
(4, '2017', 'April', '52000'),
(5, '2017', 'May', '67000'),
(6, '2017', 'June', '74000'),
(7, '2017', 'July', '71000'),
(8, '2017', 'August', '76000'),
(9, '2017', 'September', '80000'),
(10, '2017', 'October', '86000'),
(11, '2017', 'November', '88000'),
(12, '2017', 'December', '76000'),
(13, '2018', 'January', '92000'),
(14, '2018', 'February', '96000'),
(15, '2018', 'March', '105000'),
(16, '2018', 'April', '112000'),
(17, '2018', 'May', '120000'),
(18, '2018', 'June', '128000'),
(19, '2018', 'July', '116000'),
(20, '2018', 'August', '112000'),
(21, '2018', 'September', '129000'),
(22, '2018', 'October', '139000'),
(23, '2018', 'November', '140000'),
(24, '2018', 'December', '146000'),
(25, '2019', 'January', '151000'),
(26, '2019', 'February', '146000'),
(27, '2019', 'March', '160000'),
(28, '2019', 'April', '164000'),
(29, '2019', 'May', '185000'),
(30, '2019', 'June', '176000');

--
-- Indexes for dumped tables
--

--
-- Indexes for table `chart_data`
--
ALTER TABLE `chart_data`
  ADD PRIMARY KEY (`id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `chart_data`
--
ALTER TABLE `chart_data`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=31;


After this, We have to go Codeigniter framework working folder and open application/config/database.php and under this file, we have to define follow mysql database configuration for make database connection.


<?php

$active_group = 'default';
$query_builder = TRUE;

$db['default'] = array(
 'dsn' => '',
 'hostname' => 'localhost',
 'username' => 'root',
 'password' => '',
 'database' => 'testing',
 'dbdriver' => 'mysqli',
 'dbprefix' => '',
 'pconnect' => FALSE,
 'db_debug' => (ENVIRONMENT !== 'production'),
 'cache_on' => FALSE,
 'cachedir' => '',
 'char_set' => 'utf8',
 'dbcollat' => 'utf8_general_ci',
 'swap_pre' => '',
 'encrypt' => FALSE,
 'compress' => FALSE,
 'stricton' => FALSE,
 'failover' => array(),
 'save_queries' => TRUE
);

?>


Define Base Url in Codeingiter


After making Mysql Database connection in Codeigniter Application. Now we want to define base url of this Codeigniter application. For this we have to open application/config/config.php file and under this we have to define base url of this Codeigniter Application.


<?php

......

$config['base_url'] = 'http://localhost/tutorial/codeigniter/';

.......

?>


Create Controllers in Codeigniter


Codeigniter framework is based on MVC style framework. So, here we want to make controller for handle http request. In Codeigniter controllers file has been stored under application/controllers folder. In this tutorial we have make Dynamic_chart.php controller file. In this class we have make following method.

index() - This is the root method of this controller class. In this method we have get the unique year list for fill year dropdown list at view file and this method has been load view file in browser.

fetch_data() - This method has received ajax request for fetch particular year profit data from Mysql Table. It will received ajax for particular year data and send year data to model class, and modal class send back profit data to this controller method and it will convert data into json format and send back to Ajax requst. So this simple process of this method for received year data and send that year profit data to ajax request.

application/controllers/Dynamic_chart.php

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Dynamic_chart extends CI_Controller {

 public function __construct()
 {
  parent::__construct();
  $this->load->model('dynamic_chart_model');
 }

 function index()
 {
  $data['year_list'] = $this->dynamic_chart_model->fetch_year();
  $this->load->view('dynamic_chart', $data);
 }

 function fetch_data()
 {
  if($this->input->post('year'))
  {
   $chart_data = $this->dynamic_chart_model->fetch_chart_data($this->input->post('year'));
   
   foreach($chart_data->result_array() as $row)
   {
    $output[] = array(
     'month'  => $row["month"],
     'profit' => floatval($row["profit"])
    );
   }
   echo json_encode($output);
  }
 }
 
}

?>


Create Models in Codeigniter


Models class mainly used for Database operation in Codeigniter framework. Here we have store models class in application/models/Dynamic_chart_model.php this folder. In this class we have make following method.

fetch_year() - This method has been used for get unique year data.

fetch_chart_data($year) - This method has been used for get particular year profit data. Year value has been get from this method argument and based on that year argument, it has fetch that year profit data.

application/models/Dynamic_chart_model.php

<?php

class Dynamic_chart_model extends CI_Model
{
 function fetch_year()
 {
  $this->db->select('year');
  $this->db->from('chart_data');
  $this->db->group_by('year');
  $this->db->order_by('year', 'DESC');
  return $this->db->get();
 }

 function fetch_chart_data($year)
 {
  $this->db->where('year', $year);
  $this->db->order_by('year', 'ASC');
  return $this->db->get('chart_data');
 }
}

?>


Create Views in Codeigniter


Views file has been display HTML output in browser. Here views file has been store under application/views folder and under this we have make dynamic_chart.php file. In this file we have used jQuery, Bootstrap and Google chart library. In this file you can find javascript and Ajax code for populate data Bar or Column chart by using Google chart library. Below you can find complete source code of this file.

application/views/dynamic_chart.php

<html>
<head>
    <title>Dynamic Column Chart in Codeigniter using Ajax</title>
    
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
 <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<body>
 <div class="container">
  <br />
  <h3 align="center">Dynamic Column Chart in Codeigniter using Ajax</h3>
  <br />
  <div class="panel panel-default">
            <div class="panel-heading">
                <div class="row">
                    <div class="col-md-9">
                        <h3 class="panel-title">Month Wise Profit Data</h3>
                    </div>
                    <div class="col-md-3">
                        <select name="year" id="year" class="form-control">
                            <option value="">Select Year</option>
                        <?php
                        foreach($year_list->result_array() as $row)
                        {
                            echo '<option value="'.$row["year"].'">'.$row["year"].'</option>';
                        }
                        ?>

                        </select>
                    </div>
                </div>
            </div>
            <div class="panel-body">
                <div id="chart_area" style="width: 1000px; height: 620px;"></div>
            </div>
        </div>
 </div>
</body>
</html>

<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">

google.charts.load('current', {packages:['corechart', 'bar']});
google.charts.setOnLoadCallback();

function load_monthwise_data(year, title)
{
    var temp_title = title + ' ' + year;
    $.ajax({
        url:"<?php echo base_url(); ?>dynamic_chart/fetch_data",
        method:"POST",
        data:{year:year},
        dataType:"JSON",
        success:function(data)
        {
            drawMonthwiseChart(data, temp_title);
        }
    })
}

function drawMonthwiseChart(chart_data, chart_main_title)
{
    var jsonData = chart_data;
    var data = new google.visualization.DataTable();
    data.addColumn('string', 'Month');
    data.addColumn('number', 'Profit');

    $.each(jsonData, function(i, jsonData){
        var month = jsonData.month;
        var profit = parseFloat($.trim(jsonData.profit));
        data.addRows([[month, profit]]);
    });

    var options = {
        title:chart_main_title,
        hAxis: {
            title: "Months"
        },
        vAxis: {
            title: 'Profit'
        },
        chartArea:{width:'80%',height:'85%'}
    }

    var chart = new google.visualization.ColumnChart(document.getElementById('chart_area'));

    chart.draw(data, options);
}

</script>

<script>
    
$(document).ready(function(){
    $('#year').change(function(){
        var year = $(this).val();
        if(year != '')
        {
            load_monthwise_data(year, 'Month Wise Profit Data For');
        }
    });
});

</script>


Check Output in Browser


Now our all code is ready and we want to check output of above code. For this we have to go browser and write our base_url() like http://localhost/tutorial/codeigniter/dynamic_chart and press enter. It will load output of above code in browser. For check dynamic column or bar chart you have to select year from select box. After selecting year from select box you can get profit data of that year in populated Column or Bar chart without refresh of web page. So this way you can display selected year profit data on web page in Column chart format without refresh of web page. So, this is complete process of populate Google Chart Library Column chart with Dynamic Data by using Ajax in Codeigniter Framework.