Jump to content

[SOLVED] dynamic reload


NickG21

Recommended Posts

hey everyone, i have a pricing site that i am trying to make have capabilities of reloading with all prices in euros, lyra, etc.... and back to USD depending on the symbol clicked by the user.  is there any php scripts written that will produce a result like this? if not, could someone try and point me in a general direction of how to accomplish this?
thank you
Link to comment
https://forums.phpfreaks.com/topic/32111-solved-dynamic-reload/
Share on other sites

Depend how much PHP you know

Personally, I would store the Currency in a Session
Then show the price Depending the the currency Session
For example

[code]
<?php
$CurrencySymbols = array( 1 => "\$", 2 => "€", 3 => "£");
//Examples Made Up
$CurrencyExchangeRate = array(1 => 0, 2 => 0.6, 3 => 0.4);

$_SESSION["CurrencyID"] = isset($_SESSION["CurrencyID"]) ? $_SESSION["CurrencyID"] : 1;

$ItemPrice = 80;

$CurrencyPrice = $ItemPrice * $CurrencyExchangeRate[$_SESSION["CurrencyID"];
echo $CurrencySymbols[$_SESSION["CurrencyID"].$CurrencyPrice;

?>
[/code]

and to change the CurrencyID
At the top of the script

[code]

if(isset($_GET["currencyID"])){
if(is_numeric($_GET["currencyID"]){
$_SESSION["CurrencyID"] = $_GET["currencyID"];
}
}

<a href='".$_SERVER['PHP_SELF']."?currencyID=1'>USD</a><br />
<a href='".$_SERVER['PHP_SELF']."?currencyID=2'>Euro</a><br />
<a href='".$_SERVER['PHP_SELF']."?currencyID=3'>British Sterling</a><br />
[/code]
Link to comment
https://forums.phpfreaks.com/topic/32111-solved-dynamic-reload/#findComment-149012
Share on other sites

if anyone can further elaborate for me on what exactly this code means with sessions i would appreciate it.  i understand what it is doing but do not understand exactly how it runs through and reloads the site with the altered prices??
thank you
Link to comment
https://forums.phpfreaks.com/topic/32111-solved-dynamic-reload/#findComment-149321
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.