Download Script
Application made with PHP and JavaScript that displays and converts currency exchange rates with data from European Central Bank (ECB).
This script displays foreign exchange rates according to a base currency, and it can convert the sum of a currency in the other currencies (optionally you can calculate the sum with a VAT percentage).
The script uses the exchange rates from an .xml file directly from ECB, and can be registered into a MySQL database. It uses cache file that is actualized every 5 hours and around 16:00 CET (when data from ECB is usually updated).
- This application can easily be included in any web page, with a simple HTML code. Installation instructions in a "readme.txt" file in the archive with the script.
Currency Rate - ECB
Installation Instructions
- Download and unzip the archive from the Download link (above).
- By default the script uses only text file with data from ECB saved in the "cache" folder. If you want to register data into a MySQL database, open the file "ce_ecb.php" and edit the values of these constants: STORE and CONN_MYSQL.
- For STORE, replace 'file' with 'mysql'.
- In CONN_MYSQL add your data to connect to MySQL:
['host'=>'localhost', 'user'=>'user_name', 'pass'=>'password', 'bdname'=>'db_name']
- Copy the "ce_ecb" folder in the Root folder of your website (www, public_html or htdocs).
- Give writable permissions to the "cache" directory, CHMOD(0755), or 0777.
- If you register data in MySQL, access the page "create_table.php" in your browser (in the "ce_ecb" folder) to create the table in your database.
//site_name.net/ce_ecb/create_table.php
- In the page where you want to include this script add the following HTML code (in the place where you want to display this application):
<div id='ce_ecb' data-def_ce='EUR: USD, GBP, HKD, JPY' data-cv_ce='1'>
<h4>Currency Rate - ECB</h4>
</div>
<script src='/ce_ecb/ce_ecb.js'></script>
- The "data-def_ce
" attribute contains these values: "BASE: currencies to be initially displayed" (separated by commas), in order of display.
For example, in the code above, EUR is the base, and the script will display the rates for the specified foreign currencies: USD, GBP, HKD, JPY (according to base). Below is the list of valid currencies.
- The "data-cv_ce
" attribute determines to add or not the currency converter area. Put the value 0 if you want to not display the converter area ( data-cv_ce="0"
).
- The VAT value can be changed in the "ce_ecb.js" file (it is also editable in the page), in the code:
'..<b id="cv_vat" contenteditable>9</b> %..'
Currency list
AUD - Australian dollar
BGN - Bulgarian lev
BRL - Brazilian real
CAD - Canadian dollar
CHF - Swiss franc
CNY - Chinese yuan renminbi
CZK - Czech koruna
DKK - Danish krone
EUR - Euro
GBP - Pound sterling
HKD - Hong Kong dollar
HRK - Croatian kuna
HUF - Hungarian forint
IDR - Indonesian rupiah
ILS - Israeli shekel
INR - Indian rupee
ISK - Icelandic krona
JPY - Japanese yen
KRW - South Korean won
MXN - Mexican peso
NOK - Norwegian krone
NZD - New Zealand dollar
PHP - Philippine piso
PLN - Polish zloty
RON - Romanian leu
RUB - Russian rouble
SEK - Swedish krona
SGD - Singapore dollar
THB - Thai baht
TRY - Turkish lira
USD - US dollar
ZAR - South African rand
Daily Test with Code Example
HTML
CSS
JavaScript
PHP-MySQL
Which HTML element can be used to embed a SWF flash content?
<object> <div> <script><object type="application/x-shockwave-flash" data="file.swf" width="500" height="250">
<param name="src" value="file.swf" />
Your browser not support SWF.
</object>
Which CSS pseudo-class adds a style to an input form field that has keyboard input focus?
:active :focus :hoverinput:focus {
background-color: #88fe88;
}
Click on the instruction which converts a JSON string into a JavaScript object.
JSON.stringify(javascript_object) object.toString() JSON.parse(json_string)var jsnstr = '{"url": "http://coursesweb.net/", "title": "Web Development Courses"}';
var obj = JSON.parse(jsnstr);
alert(obj.url);
Indicate the PHP function which can be used to create or write a file on server.
fopen() file_put_contents() file_get_contents()if (file_put_contents("file.txt", "content")) echo "The file was created";
else echo "The file can not be created";