Google’s Currency Converter and JSON API

There are a lot of online Currency Converter Calculators on web. I want to share one more with you.
You can believe it; because its Google’s Currency Converter Calculator. It can be used to see changes live for currency and foreign exchange rates with this free currency converter.

Here is the Google’s Currency Converter

Open JSON API
Good news is here – Google have a secrete API for Currency Conversion. Its a simple open API you can use for all type of foreign currencies.

How to use it?
If you want currency converter £ to dollars, use it like this –
http://www.google.com/ig/calculator?hl=en&q=1GBP=?USD

If you want to calculate currency converter $ to £ –
http://www.google.com/ig/calculator?hl=en&q=1USD=?GBP

You can change value of input currency, for example you want to know the value for $100 in India Rupees
http://www.google.com/ig/calculator?hl=en&q=100USD=?PKR

Hope you enjoyed the post.

Custom Pagination for CI

I have tried Codeigniter pagination for some grid but its bump. So I decide to write own pagination for Codeigniter you can also use it for Core PHP with some alteration. So here is the code:

/*
* @param
* total = number of records
* diff = number of records per page to display
* base_url = url of the page where record is being display
* page = current page displaying
*/
public function pagination($total, $diff, $base_url,$page) {
$output = '

';
$output .= '
Display ';
$output .= form_dropdown('diff', array(15, 30, 45, 60));
$output .= 'Replies';
$output .= '
Next';
$output .= '';
$output .= '
';
$output .= '

';
$output .= 'Previous
';
//generate pagination for specific page
$i = ($page>0 && $page<5)?0:$page-5;
$j = 0;
$total_page = ($page<$total && ($page5))?'...':'';
$page = ($page>0 && $page<5)?0:$page-5;
for (; $i <= $total; $i+=$diff) { $j++; $page++; if ($page >= $total/$diff){
break;
}
if ($j < 10) { // generate pagination with sorting through field is on if ($this->CI->input->get('field') != "")
{
$total_page .= ' ' . $page . ' ';
}
//generate simple pagination link
else
{
$total_page .= ' ' . $page . ' ';
}
}
else
{
$total_page .= '...';
break;
}
}
$output .= $total_page;
$output .= '

';

return $output;
}

Hope this will help, Happy coding.