Code Example: Utilizing Web Services in PHP #16

PHP code to grab the best provincial mortgage rate:function find_mortgaze_rate($url){ // create a new cURL resource   $ch = curl_init();  // set URL and other appropriate options    curl_setopt($ch, CURLOPT_URL, $url);    curl_setopt($ch, CURLOPT_USERPWD, "username:password"); curl_setopt($ch, CURLOPT_HEADER, 0);    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);        // grab URL and pass it to the browser  $result = curl_exec($ch);   $bestRates = json_decode($result, true);    return $bestRates[1][5][0]['rate']; // close cURL resource, and free up system resources    curl_close($ch);    return $bestMortgaze;    }//supply URL to ProvidingMortgazeRatesForEachProvinceForDifferentYearsAndType$bestMortgaze = find_mortgaze_rate($urlToTheWebService);
Sample JavaScript Function to calculate the monthly mortgaze paymentfunction calculate(){    var rate = document.getElementById('txtRate').value;    var homePrice = document.getElementById('txtHomePrice').value;  var percentDown = document.getElementById('txtDownpaymentPercent').value;   var amortization = document.getElementById('amortization').value;   var monthlyPayment = can_mortgage_payment_purchase(homePrice, percentDown/100,  rate/100, amortization, 12, 1); document.getElementById('monthlyPayment').value = '$'+monthlyPayment.toFixed(2);}
Calculator Form Code       
Best 5 Year Fixed Rate:
Home Price:
Downpayment Percentage:
Amortization: 25 Years 30 Years
Mortgage Payment:

From: http://sitestree.com/?p=5302
Categories:16
Tags:
Post Data:2009-11-03 18:40:09

    Shop Online: <a href='https://www.ShopForSoul.com/' target='new' rel="noopener">https://www.ShopForSoul.com/</a>
    (Big Data, Cloud, Security, Machine Learning): Courses: <a href='http://Training.SitesTree.com' target='new' rel="noopener"> http://Training.SitesTree.com</a> 
    In Bengali: <a href='http://Bangla.SaLearningSchool.com' target='new' rel="noopener">http://Bangla.SaLearningSchool.com</a>
    <a href='http://SitesTree.com' target='new' rel="noopener">http://SitesTree.com</a>
    8112223 Canada Inc./JustEtc: <a href='http://JustEtc.net' target='new' rel="noopener">http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning) </a>
    Shop Online: <a href='https://www.ShopForSoul.com'> https://www.ShopForSoul.com/</a>
    Medium: <a href='https://medium.com/@SayedAhmedCanada' target='new' rel="noopener"> https://medium.com/@SayedAhmedCanada </a>