Results 1 to 3 of 3

Thread: Auto convert currency on webpage

  1. #1
    Join Date
    Sep 2004
    Location
    Johannesburg, South Africa
    Posts
    383
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Question Auto convert currency on webpage

    Hi Guys & Girls

    I'm doing a website (http://www.silvertreeestates.co.za)

    In the list on properties, you will see the price of the property in ZAR, what I wanted to do was add the US$ and Euro amount next to this, but I want the page to automatically check for the latest exchange rates and use that value to display on the page.

    Is this possible and how would I go about it

    What I have at the moment:
    Click image for larger version. 

Name:	zar.jpg 
Views:	97 
Size:	43.0 KB 
ID:	5960
    What I would like to have fully automated
    Click image for larger version. 

Name:	eorp.jpg 
Views:	80 
Size:	34.9 KB 
ID:	5961

    Best Regards, Simon
    Very Best Rgds, Simonf :cool:
    __________________________________
    My Site | E-Mail Me | RSA Search Engine

  2. #2
    Join Date
    Oct 2016
    Posts
    2
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    you can check this code, it might help you.

    Code:
    function currency($from_Currency,$to_Currency,$amount) {
        $amount = urlencode($amount);
        $from_Currency = urlencode($from_Currency);
        $to_Currency = urlencode($to_Currency);
        $url = "http://www.google.com/ig/calculator?hl=en&q=$amount$from_Currency=?$to_Currency";
        $ch = curl_init();
        $timeout = 0;
        curl_setopt ($ch, CURLOPT_URL, $url);
        curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch,  CURLOPT_USERAGENT , "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)");
        curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
        $rawdata = curl_exec($ch);
        curl_close($ch);
        $data = explode('"', $rawdata);
        $data = explode(' ', $data['3']);
        $var = $data['0'];
        return round($var,2);
    }
    Last edited by jscheuer1; 10-28-2016 at 02:04 PM. Reason: format code

  3. The Following User Says Thank You to sajid26425 For This Useful Post:

    simonf (10-28-2016)

  4. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,963
    Thanks
    66
    Thanked 3,338 Times in 3,299 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by sajid26425 View Post
    you can check this code, it might help you.

    Code:
    function currency($from_Currency,$to_Currency,$amount) {
        $amount = urlencode($amount);
        $from_Currency = urlencode($from_Currency);
        $to_Currency = urlencode($to_Currency);
        $url = "http://www.google.com/ig/calculator?hl=en&q=$amount$from_Currency=?$to_Currency";
        $ch = curl_init();
        $timeout = 0;
        curl_setopt ($ch, CURLOPT_URL, $url);
        curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch,  CURLOPT_USERAGENT , "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)");
        curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
        $rawdata = curl_exec($ch);
        curl_close($ch);
        $data = explode('"', $rawdata);
        $data = explode(' ', $data['3']);
        $var = $data['0'];
        return round($var,2);
    }
    That's actually from this thread:

    http://stackoverflow.com/questions/1...ncy-conversion
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Similar Threads

  1. Currency Auto Format - Please Help
    By jpaulraj in forum JavaScript
    Replies: 4
    Last Post: 10-19-2013, 11:36 AM
  2. Currency Convertion
    By casimirrex in forum ASP
    Replies: 2
    Last Post: 07-17-2010, 08:00 AM
  3. JS currency converter?
    By NickNameDrive in forum JavaScript
    Replies: 3
    Last Post: 05-27-2010, 08:58 PM
  4. Replies: 1
    Last Post: 07-01-2009, 11:56 AM
  5. convert currency selection box to a drop down manu
    By jackson in forum Looking for such a script or service
    Replies: 9
    Last Post: 12-28-2008, 04:12 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •