Exchange Rates
r; } } } elseif (strcmp($to,"US") == 0) { $curquery = "SELECT " . $amount . "*1.0/rate AS r FROM exchange_rate WHERE date LIKE \"" . $year . "-" . $month . "%\" AND from_currency = \"US\" AND to_currency = \"" . $from . "\""; $curresults = mysql_query($curquery) or die("Currency query failed : " . mysql_error()); $num_cur = mysql_num_rows($curresults); if ($num_cur != 1) { echo "No data or incorrect query."; } else { while ($cur = mysql_fetch_object($curresults)) { $r_num = (float)$cur->r; } } } else { $firstquery = "SELECT " . $amount . "*1.0/rate AS r FROM exchange_rate WHERE date LIKE \"" . $year . "-" . $month . "%\" AND from_currency = \"US\" AND to_currency = \"" . $from . "\""; $firstresults = mysql_query($firstquery) or die("Currency query failed : " . mysql_error()); $num_first = mysql_num_rows($firstresults); if ($num_first != 1) { $num_cur == 0; } else { while ($first = mysql_fetch_object($firstresults)) { $first_r_num = $first->r; } $secondquery = "SELECT " . $first_r_num . "*rate AS r FROM exchange_rate WHERE date LIKE \"" . $year . "-" . $month . "%\" AND from_currency = \"US\" AND to_currency = \"" . $to . "\""; $secondresults = mysql_query($secondquery) or die("Currency query failed : " . mysql_error()); $num_second = mysql_num_rows($secondresults); if ($num_second != 1) { $num_cur == 0; echo "No data or incorrect query."; } else { while ($second = mysql_fetch_object($secondresults)) { $r_num = (float)$second->r; } $num_cur=1; } } } if ($num_cur == 1) { if (strcmp($acc,"2")==0) { printf('%7.2f',$r_num); } else { printf('%7.4f', $r_num); } } } $show = $_GET['show']; $from = $_GET['from']; $to = $_GET['to']; $month = $_GET['month']; $year = $_GET['year']; $amount = $_GET['amount']; $currencies = array("AU","TH","US","EU","UK","CN","JP"); $notes = array("AU dollars","baht","US dollars","euro","pounds","yuan","yen"); $names = array("Australia","Thailand","United States","Europe","United Kingdom","China","Japan"); $years=array("2009","2008","2007","2006"); $months=array("01","02","03","04","05","06","07","08","09","10","11","12"); $numCurrencies=7; reset($currencies); reset($notes); reset($months); reset($years); reset($names); if (strcmp($show,"history")==0) { $j = 0; $found = 0; foreach ($currencies as $i) { if (strcmp($i,$from)!=0) { if ($found == 0) { $j = $j+1; } } else { $found=1; } } foreach ($years as $y) { $nomore=1; echo '' . $y . ", " . $notes[$j] . '
'; echo 'Month | '; foreach ($currencies as $c) { if (strcmp($c,$from)!=0) { echo '' . $c . ' | '; } } echo '
---|---|
' . monthAsString($months[$k]) . ' | '; foreach ($currencies as $c) { if (strcmp($c,$from)!=0) { echo ''; convertCurrency(1.0,$from,$c,$months[$k],$y,0); echo ' | '; } } echo '
As at ' . monthAsString($month) . ' ' . $year . ', ' . $amount . ' ' . $notes[$j] . ' was worth ...
'; echo 'Currency | '; echo 'Rate | '; echo 'Value | '; echo '
---|---|---|
' . $i . ' | '; echo ''; convertCurrency(1.0,$from,$i,$month,$year,0); echo ' | '; echo ''; convertCurrency($amount,$from,$i,$month,$year,2); echo ' ' . $notes[$j]; echo ' | '; echo '
Currency Conversion
'; echo 'Historical Exchange Rates
'; echo 'Select a country/region to see the historical exchange rates to the other currencies:'; echo '- ';
for ($i = 0; $i < $numCurrencies; $i++) {
echo '
- ' . $names[$i] . ' '; } echo '
Other Conversions
'; echo ''; } include 'dbclose.php'; ?>Created on Tue, 09 Jan 2007, 1:04am
Last changed on Tue, 12 Jun 2012, 4:41pm