473,657 Members | 2,490 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHP Currency converter

AdrianH
1,251 Recognized Expert Top Contributor
Does anyone know where I can get a PHP currency converter?


Adrian
Jun 11 '07 #1
12 3277
pbmods
5,821 Recognized Expert Expert
Erm... from Google?

(plus or minus 20 characters :P)
Jun 12 '07 #2
AdrianH
1,251 Recognized Expert Top Contributor
Erm... from Google?

(plus or minus 20 characters :P)
Ha ha .... ha! You think I didn't try Google? :p

I did find a few, but they required registring to some site. Blech! And even when I did, I didn't get an email for at least an hour. Actually, I stopped looking after that. I gave them my spam account anyway. ;)

When I tried using different key words I finally found some. I think the words were: Ajax, currency and converter. Pain in the ass trying to find somethings. :(

But I did find it. Thanks.


Adrian
Jun 12 '07 #3
Motoma
3,237 Recognized Expert Specialist
Ha ha .... ha! You think I didn't try Google? :p

I did find a few, but they required registring to some site. Blech! And even when I did, I didn't get an email for at least an hour. Actually, I stopped looking after that. I gave them my spam account anyway. ;)

When I tried using different key words I finally found some. I think the words were: Ajax, currency and converter. Pain in the ass trying to find somethings. :(

But I did find it. Thanks.


Adrian
Ermmm. What currencies are you trying to convert?
Do you need them updated in real time?
I bet I could whip something up real fast.
Jun 12 '07 #4
Motoma
3,237 Recognized Expert Specialist
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head><title>Motoma Pwnz0rz teh curency!!!!!11one
  3. </title></head>
  4. </body>
  5. <form method="post">
  6.  
  7. <?php
  8. $currArr = array( 'Dollars' => 1, 'Euros' => .78, 'Linden' => 1000);
  9.  
  10. if(isset($_POST['submit']))
  11. {
  12.   $textBox = '<input type="text" name="dollars" value="'.$_POST['dollars'].'" />';
  13.   $optionBox = '<select name="currency">';
  14.   foreach($currArr as $name => $value)
  15.   {
  16.     if($_POST['currency'] == $value) $optionBox .= '<option value='.$value.' selected>';
  17.     else $optionBox .= '<option value='.$value.' >';
  18.     $optionBox .= $name;
  19.   }
  20.   $optionBox .= '</select>';
  21.   $result = '<input type="text" name="result" value="'.$_POST['dollars'] * $_POST['currency'].'">';
  22. }
  23. else
  24. {
  25.   $textBox = '<input type="text" name="dollars" />';
  26.   $optionBox = '<select name="currency">';
  27.   foreach($currArr as $name => $value) $optionBox .= '<option value='.$value.' >'.$name;
  28.   $optionBox .= '</select>';
  29.   $result = '<input type="text" name="result" />';
  30. }
  31.  
  32. echo $textBox.$optionBox.'<input type="submit" name="submit">'.$result;
  33. ?>
  34.  
  35. </form>
  36. </body>
  37. </html>
  38.  
Don't make fun of me if it doesn't work.
Jun 12 '07 #5
AdrianH
1,251 Recognized Expert Top Contributor
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head><title>Motoma Pwnz0rz teh curency!!!!!11one
  3. </title></head>
  4. </body>
  5. <form method="post">
  6.  
  7. <?php
  8. $currArr = array( 'Dollars' => 1, 'Euros' => .78, 'Linden' => 1000);
  9.  
  10. if(isset($_POST['submit']))
  11. {
  12.   $textBox = '<input type="text" name="dollars" value="'.$_POST['dollars'].'" />';
  13.   $optionBox = '<select name="currency">';
  14.   foreach($currArr as $name => $value)
  15.   {
  16.     if($_POST['currency'] == $value) $optionBox .= '<option value='.$value.' selected>';
  17.     else $optionBox .= '<option value='.$value.' >';
  18.     $optionBox .= $name;
  19.   }
  20.   $optionBox .= '</select>';
  21.   $result = '<input type="text" name="result" value="'.$_POST['dollars'] * $_POST['currency'].'">';
  22. }
  23. else
  24. {
  25.   $textBox = '<input type="text" name="dollars" />';
  26.   $optionBox = '<select name="currency">';
  27.   foreach($currArr as $name => $value) $optionBox .= '<option value='.$value.' >'.$name;
  28.   $optionBox .= '</select>';
  29.   $result = '<input type="text" name="result" />';
  30. }
  31.  
  32. echo $textBox.$optionBox.'<input type="submit" name="submit">'.$result;
  33. ?>
  34.  
  35. </form>
  36. </body>
  37. </html>
  38.  
Don't make fun of me if it doesn't work.
HA-HA! (bully from the Simpsons) ;)

I've not tried it, but I would like it to convert all different types. Apperently, the one I've got and am still looking at will download a csv file from yahoo's finantial pages and then it will be able to convert and update using AJAX.

I'm still trying to get it to work. :(


Adrian
Jun 12 '07 #6
Motoma
3,237 Recognized Expert Specialist
HA-HA! (bully from the Simpsons) ;)

I've not tried it, but I would like it to convert all different types. Apperently, the one I've got and am still looking at will download a csv file from yahoo's finantial pages and then it will be able to convert and update using AJAX.

I'm still trying to get it to work. :(

Adrian
You could do the same thing with mine: use fopen and fgetcsv to read the CSV file, and write the data to an associative array. Take the input currency, convert to a standard medium, and convert to your output currency.
I like the associative array method better, as it is easier to use: you don't need to keep track of every currency's exchange rate with every other currency (an n squared problem). Instead you keep track of every currency in relation to a base (in my case, dollars) and do all conversions with that.
The basic algorithm would be:

(source amount) / (source rate) * (currency rate)
Jun 12 '07 #7
r035198x
13,262 MVP
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head><title>Motoma Pwnz0rz teh curency!!!!!11one
  3. </title></head>
  4. </body>
  5. <form method="post">
  6.  
  7. <?php
  8. $currArr = array( 'Dollars' => 1, 'Euros' => .78, 'Linden' => 1000);
  9.  
  10. if(isset($_POST['submit']))
  11. {
  12.   $textBox = '<input type="text" name="dollars" value="'.$_POST['dollars'].'" />';
  13.   $optionBox = '<select name="currency">';
  14.   foreach($currArr as $name => $value)
  15.   {
  16.     if($_POST['currency'] == $value) $optionBox .= '<option value='.$value.' selected>';
  17.     else $optionBox .= '<option value='.$value.' >';
  18.     $optionBox .= $name;
  19.   }
  20.   $optionBox .= '</select>';
  21.   $result = '<input type="text" name="result" value="'.$_POST['dollars'] * $_POST['currency'].'">';
  22. }
  23. else
  24. {
  25.   $textBox = '<input type="text" name="dollars" />';
  26.   $optionBox = '<select name="currency">';
  27.   foreach($currArr as $name => $value) $optionBox .= '<option value='.$value.' >'.$name;
  28.   $optionBox .= '</select>';
  29.   $result = '<input type="text" name="result" />';
  30. }
  31.  
  32. echo $textBox.$optionBox.'<input type="submit" name="submit">'.$result;
  33. ?>
  34.  
  35. </form>
  36. </body>
  37. </html>
  38.  
Don't make fun of me if it doesn't work.
you could at least have made it possible for users to specify the conversion rates ...
Jun 12 '07 #8
Purple
404 Recognized Expert Contributor
Hi,

did you take a look at xe.com ?

xe.com

Purple
Jun 12 '07 #9
r035198x
13,262 MVP
Hi,

did you take a look at xe.com ?

xe.com

Purple
Long form to fill in but the screen shot looks better than motoma's!
Jun 12 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

2
4432
by: techy techno | last post by:
hii Experts..!! I need someone to tell me where I can get a Currency Converter like http://cconv.textor.com please can someone tell me where I can get it I need it for free + I dont need any link of the co. the code for this is here but when I change it it just says unauthorize
7
4064
by: meenasamy | last post by:
Hi all, i need to create a function that takes three parameters( Original currency, needed currency, amount) i need to convert from the original currency to the needed currency the amount and return the new amount in the needed currency, I need this function to work real time (obtaining real time currency exchange rates), any ideas???
2
1837
by: Rash33d | last post by:
Hi there! could som1 please help me out? i need toknow if there's something wrong with this javascript code. The code is meant to give the american dollar and european equivalent of a price. i.e when i type a price in pounds, it gives me the price in dollars and euros. Thanks in advance function fix(thenumber,noplaces){ // returns the number to n decimal places var oldnumber=thenumber;
10
3872
by: jayender.vs | last post by:
Hello guys, I need to know the Currency conversion code in Javascript Say for example i got 2 textbox .. where i enter a number (singapore doller value) and i provide a button and in the next text box i should get the value in US doller value. Waiting for ur response, Ciao, Jay
2
2816
by: Raj | last post by:
Is there a current converter web service available? Currency rates are to be as per latest exchange rates. Raj.
16
9493
by: xjohnx | last post by:
Hi, I'm hoping someone can help me I am quite new to Javascript and have had to create a programme which converts dollars into euros and vice versa, here is my script which is working var currency; var amountEntered; currency = window.prompt('Please enter 0 to convert from Dollars to euros and 1 to convert form euros to dollars',''); currency = parseFloat(currency); while (currency < 0 || currency > 1) { currency =...
25
5929
by: mereba | last post by:
Hello My country Ghana is changing its currency. I want to write a small programme in C++ that can covert from the old currency into the new one. I would like this programme to run behind a simple calculator- looking interface. I'm quite new to C++, and I would need some help. Please any suggestion is welcome :) The following is what I have been able to do so far:
7
3764
by: tararreb | last post by:
#include<stdio.h> /*This line is standard input output, # is directive, include is keyword, and stdio.h is header file*/ #include<stdlib.h> /*This line is standard input output, # is directive, include is keyword, and stdlib.h is standard library defininition*/ #include<math.h> /*This line is standard input output, # is directive, include is keyword, and math.h is mathematical declarations*/ main (void)
1
9219
by: katie20 | last post by:
Hi everyone, I have written a code in order to produce a currency converter. My program will be designed to convert pounds into euros using visual basic programming. I have two text boxes and one button(convert) I have written the code, but i have come across alot of errors. Can anyone help me? Here is my code in full: Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles...
0
8420
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8324
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8842
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8740
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8617
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7353
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6176
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1733
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.