473,410 Members | 1,952 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,410 software developers and data experts.

PHP Currency converter

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


Adrian
Jun 11 '07 #1
12 3255
pbmods
5,821 Expert 4TB
Erm... from Google?

(plus or minus 20 characters :P)
Jun 12 '07 #2
AdrianH
1,251 Expert 1GB
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 Expert 2GB
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 Expert 2GB
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 Expert 1GB
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 Expert 2GB
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 8TB
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 Expert 256MB
Hi,

did you take a look at xe.com ?

xe.com

Purple
Jun 12 '07 #9
r035198x
13,262 8TB
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
Motoma
3,237 Expert 2GB
Long form to fill in but the screen shot looks better than motoma's!
You think you're pretty smart, what with your 5000 posts eh? Won't be feeling so spiffy once I go and delete all of your posts. You'll be sitting there with roughly a dozen in your name.
Jun 12 '07 #11
r035198x
13,262 8TB
You think you're pretty smart, what with your 5000 posts eh? Won't be feeling so spiffy once I go and delete all of your posts. You'll be sitting there with roughly a dozen in your name.
Don't forget my arm is longer than yours and reaches all the small and nasty corners.
Jun 12 '07 #12
Motoma
3,237 Expert 2GB
Don't forget my arm is longer than yours and reaches all the small and nasty corners.
Meh.
'nuff said.
Jun 12 '07 #13

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

Similar topics

2
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...
7
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...
2
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...
10
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...
2
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
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...
25
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...
7
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,...
1
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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...

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.