Sarbrinder Singh

Web Developer

My Blog

How to calculate distance between two cordinates using select query in Codegniter

In this tutorial we calculate the distance (Km , meters , seconds) between two cordinates using Select Query in codegniter. Here we just pass thetwo address named address1 and address2 and first we calculate latitude and longitude of both address. Based on these latitude and longitude we calculate distance.
Example:-Suppose we calculate distance from Jalandhar city to Chandigarah city
"address1":"jalandhar","address2":"chandigarah"
Then function in model is :
public functio

Read More

How to calculate distance between two cordinates by passing address in Codegniter

In this tutorial we calculate the distance (Km , meters , seconds) between two cordinates using GOOGLE API. Here we just pass the two address named address1 and address2.
Example:- Suppose we calculate distance from Jalandhar city to Chandigarah city
"address1":"jalandhar", "address2":"chandigarah"
Then function in model is :
public function findDistance()
{
$from = "jalandhar";
$to = "chandigarah";
$from = urlencode($from);
$to = u

Read More

Export CSV file using PHP Codeigniter

In this tutorial, I will walk you through PHP code to export table from database using php codeigniter.Most of the time my clientsneed to download data from their database tables.Exporting to CSV is a pain in the rear for users and it leads to confusion . Today, I decided to make a very small controller that is portable and efficient for exporting full MySQL tables to Excel .
Example
Follow this example step by step:
Step 1 :Place this function in helper that is called in

Read More

Import CSV File into MySQL using PHP Codeigniter

In this tutorial, I will walk you through PHP code to import CSV file into MySQL database .The input CSV file is sent via a HTML form. I used fgetcsv() function to read the database table column data from the CSV.
Example
Follow this example step by step:
Step 1: Create HTML form to import csv file.
< form class="form-horizontal" action="" method="post" name="uploadCSV" enctype="multipart/form-data">
< div class="input-row">
< label class="col-md-4 control-label">

Read More

How to create calendar in php passing month and year

In this blog am going to discuss how we can create calendar on the base of month and year . Recently I faced a problem to create a calendar by passing month and year asa argument , trust me it is very easy to create this.Calendar is a very common element in today's web applications. Whether you are building an event booking application, appointment system or even a social network. Calendar is essential.In this tutorial, we go through steps of building a calendar in PHP. After this tutor

Read More

TCPDF error :Unable to get the size of the image

In this blog am going to discuss a common error that is occur during creating PDF using tcpdf library. "tcpdf error:-Unable to get thesize of the image" . when we create pdf using TCPDF library set all detail of single page like margin ,width header ,footer etc of a pagewhen we use any image in pdf it is better to give image and their dimensions in function .In this code we create a pdf using explicit function.
Explaination:-$pdf->Image('@' . $img, 24 ,15, '162', '10', 'PNG', ''

Read More

Best way of query builder

Sometime it is tough to handle more complex queries in mysql php. When a single php query include multiple join ,where ,group by ,having clause etc. In this blog am going to discuss "How to handle complex query with group_start and group_end method"This example is in Codeigniter. Suppose we have to select data from two tables using join , where condition ,order by clause ,group by and having clause. In this examplewe also explain How to use selected item in where clause..
NOT

Read More

How to create folder on BitBucket using Ubuntu

This tutorial is about to create folder inside the  Bitbucket . when we perform searching on them we found that  " BitBucket does not provide you with such a feature to add an folder and manage your repositories inside a folder. " but I suggest you that it is possible . In order to create folder inside bitbucket using ubuntu follow these given steps.
Step 1:- create any folder in your repository.
Step 2:- place any empty file in folder.
remember bitbucket doest not al

Read More

How to connect AWS server in php

In order to connect with aws server you must have aws account . when you create account successfully you must have set privilages to user.
Prereqistics:-
1.) .pem file
2.) .ppk file
For this you required two files. If you don't have don't worry you can download it .
3.)  install putty
PuTTY is likely the most-used SSH client for the MS Windows platform that is used to access the server.
Use the following procedure to connect to your Linux instance using an SSH c

Read More

How to set Cronjob in AWS

Hello Guys
In this blog I discuss about the cronjob setting in AWS. Amazon web services is one of the most popular platform to run large and scalable website. Amazon provide no of services to make your web application load fast etc. Configuring cron job on AWS is little bit confusing for first time and i also did not find any proper documentation to setup cron job over AWS so after google some hour and try no method share by the people i finally setup my cron job and ready to shar

Read More